Place snapshots

ABSTRACT

A database system may maintain a plurality of log records at a distributed storage system. Each of the plurality of log records may be associated with a respective change to a data page. A snapshot may be generated that is usable to read the data as of a state corresponding to the snapshot. Generating the snapshot may include generating metadata that is indicative of a particular log identifier of a particular one of the log records. Generating the snapshot may be performed without additional reading, copying, or writing of the data.

RELATED APPLICATIONS

This application claims benefit of priority to U.S. ProvisionalApplication Ser. No. 61/794,658, entitled “IN PLACE SNAPSHOTS”, whichwas filed Mar. 15, 2013, and which is incorporated herein by referencein its entirety.

BACKGROUND

Distribution of various components of a software stack can in some casesprovide (or support) fault tolerance (e.g., through replication), higherdurability, and less expensive solutions (e.g., through the use of manysmaller, less-expensive components rather than fewer large, expensivecomponents). However, databases have historically been among thecomponents of the software stack that are least amenable todistribution. For example, it can difficult to distribute databaseswhile still ensuring the so-called ACID properties (e.g., Atomicity,Consistency, Isolation, and Durability) that they are expected toprovide.

While most existing relational databases are not distributed, someexisting databases are “scaled out” (as opposed to being “scaled up” bymerely employing a larger monolithic system) using one of two commonmodels: a “shared nothing” model, and a “shared disk” model. In general,in a “shared nothing” model, received queries are decomposed intodatabase shards (each of which includes a component of the query), theseshards are sent to different compute nodes for query processing, and theresults are collected and aggregated before they are returned. Ingeneral, in a “shared disk” model, every compute node in a cluster hasaccess to the same underlying data. In systems that employ this model,great care must be taken to manage cache coherency. In both of thesemodels, a large, monolithic database is replicated on multiple nodes(including all of the functionality of a stand-alone database instance),and “glue” logic is added to stitch them together. For example, in the“shared nothing” model, the glue logic may provide the functionality ofa dispatcher that subdivides queries, sends them to multiple computenotes, and then combines the results. In a “shared disk” model, the gluelogic may serve to fuse together the caches of multiple nodes (e.g., tomanage coherency at the caching layer). These “shared nothing” and“shared disk” database systems can be costly to deploy and complex tomaintain, and may over-serve many database use cases.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating various components of a databasesoftware stack, according to one embodiment.

FIG. 2 is a block diagram illustrating a service system architecturethat may be configured to implement a web services-based databaseservice, according to some embodiments.

FIG. 3 is a block diagram illustrating various components of a databasesystem that includes a database engine and a separate distributeddatabase storage service, according to one embodiment.

FIG. 4 is a block diagram illustrating a distributed database-optimizedstorage system, according to one embodiment.

FIG. 5 is a block diagram illustrating the use of a separate distributeddatabase-optimized storage system in a database system, according to oneembodiment.

FIG. 6 is a block diagram illustrating how data and metadata may bestored on a given node of a distributed database-optimized storagesystem, according to one embodiment.

FIG. 7 is a block diagram illustrating an example configuration of adatabase volume, according to one embodiment.

FIG. 8 is a flow diagram illustrating one embodiment of a method forcreating and/or using a snapshot in a web services-based databaseservice.

FIG. 9 is a flow diagram illustrating one embodiment of a method formanipulating log records in a web services-based database service.

FIG. 10 is a block diagram illustrating a computer system configured toimplement at least a portion of a database system that includes adatabase engine and a separate distributed database storage service,according to various embodiments.

While embodiments are described herein by way of example for severalembodiments and illustrative drawings, those skilled in the art willrecognize that the embodiments are not limited to the embodiments ordrawings described. It should be understood, that the drawings anddetailed description thereto are not intended to limit embodiments tothe particular form disclosed, but on the contrary, the intention is tocover all modifications, equivalents and alternatives falling within thespirit and scope as defined by the appended claims. The headings usedherein are for organizational purposes only and are not meant to be usedto limit the scope of the description or the claims. As used throughoutthis application, the word “may” is used in a permissive sense (i.e.,meaning having the potential to), rather than the mandatory sense (i.e.,meaning must). The words “include,” “including,” and “includes” indicateopen-ended relationships and therefore mean including, but not limitedto. Similarly, the words “have,” “having,” and “has” also indicateopen-ended relationships, and thus mean having, but not limited to. Theterms “first,” “second,” “third,” and so forth as used herein are usedas labels for nouns that they precede, and do not imply any type ofordering (e.g., spatial, temporal, logical, etc.) unless such anordering is otherwise explicitly indicated.

Various components may be described as “configured to” perform a task ortasks. In such contexts, “configured to” is a broad recitation generallymeaning “having structure that” performs the task or tasks duringoperation. As such, the component can be configured to perform the taskeven when the component is not currently performing that task (e.g., acomputer system may be configured to perform operations even when theoperations are not currently being performed). In some contexts,“configured to” may be a broad recitation of structure generally meaning“having circuitry that” performs the task or tasks during operation. Assuch, the component can be configured to perform the task even when thecomponent is not currently on. In general, the circuitry that forms thestructure corresponding to “configured to” may include hardwarecircuits.

Various components may be described as performing a task or tasks, forconvenience in the description. Such descriptions should be interpretedas including the phrase “configured to.” Reciting a component that isconfigured to perform one or more tasks is expressly intended not toinvoke 35 U.S.C. §112, paragraph six, interpretation for that component.

“Based On.” As used herein, this term is used to describe one or morefactors that affect a determination. This term does not forecloseadditional factors that may affect a determination. That is, adetermination may be solely based on those factors or based, at least inpart, on those factors. Consider the phrase “determine A based on B.”While B may be a factor that affects the determination of A, such aphrase does not foreclose the determination of A from also being basedon C. In other instances, A may be determined based solely on B.

The scope of the present disclosure includes any feature or combinationof features disclosed herein (either explicitly or implicitly), or anygeneralization thereof, whether or not it mitigates any or all of theproblems addressed herein. Accordingly, new claims may be formulatedduring prosecution of this application (or an application claimingpriority thereto) to any such combination of features. In particular,with reference to the appended claims, features from dependent claimsmay be combined with those of the independent claims and features fromrespective independent claims may be combined in any appropriate mannerand not merely in the specific combinations enumerated in the appendedclaims.

DETAILED DESCRIPTION

Various embodiments of snapshot generation are disclosed. Various onesof the present embodiments may include a distributed storage system of adatabase service maintaining a plurality of log records. The log recordsmay be associated with respective changes to data stored by the databaseservice. Various ones of the present embodiments may include thedistributed storage system generating a snapshot usable to read the dataas of a state corresponding to the snapshot. Generating the snapshot mayinclude generating metadata that is indicative of a particular logidentifier (e.g., log sequence number, time stamp, etc.) of a particularone of the log records. In some embodiments, the metadata may also beindicative of a snapshot identifier. The disclosed snapshot generationtechniques may be performed without reading, copying, or writing a datapage as part of the snapshot generation.

Various embodiments of log record manipulation are also disclosed.Various ones of the present embodiments may include a distributedstorage system of a database service receiving a plurality of logrecords. Various ones of the present embodiments may also include thedistributed storage system storing the plurality of log records among aplurality of storage nodes of the distributed storage system. Variousones of the present embodiments may further include the distributedstorage system transforming the plurality of log records. Transformationmay include cropping, pruning, reducing, fusing, and/or otherwisedeleting, merging, or adding records, among other transformations.

The specification first describes an example web services-based databaseservice configured to implement the disclosed snapshot operations (e.g.,creating, deletion, use, manipulation, etc.) and log record manipulationtechniques. Included in the description of the example webservices-based database service are various aspects of the example webservices-based database service, such as a database engine and aseparate distributed database storage service. The specification thendescribes flowcharts of various embodiments of methods for snapshotoperations and log record manipulation. Next, the specificationdescribes an example system that may implement the disclosed techniques.Various examples are provided throughout the specification.

The systems described herein may, in some embodiments, implement a webservice that enables clients (e.g., subscribers) to operate a datastorage system in a cloud computing environment. In some embodiments,the data storage system may be an enterprise-class database system thatis highly scalable and extensible. In some embodiments, queries may bedirected to database storage that is distributed across multiplephysical resources, and the database system may be scaled up or down onan as needed basis. The database system may work effectively withdatabase schemas of various types and/or organizations, in differentembodiments. In some embodiments, clients/subscribers may submit queriesin a number of ways, e.g., interactively via an SQL interface to thedatabase system. In other embodiments, external applications andprograms may submit queries using Open Database Connectivity (ODBC)and/or Java Database Connectivity (JDBC) driver interfaces to thedatabase system.

More specifically, the systems described herein may, in someembodiments, implement a service-oriented database architecture in whichvarious functional components of a single database system areintrinsically distributed. For example, rather than lashing togethermultiple complete and monolithic database instances (each of which mayinclude extraneous functionality, such as an application server, searchfunctionality, or other functionality beyond that required to providethe core functions of a database), these systems may organize the basicoperations of a database (e.g., query processing, transactionmanagement, caching and storage) into tiers that may be individually andindependently scalable. For example, in some embodiments, each databaseinstance in the systems described herein may include a database tier(which may include a single database engine head node and a client-sidestorage system driver), and a separate, distributed storage system(which may include multiple storage nodes that collectively perform someof the operations traditionally performed in the database tier ofexisting systems).

As described in more detail herein, in some embodiments, some of thelowest level operations of a database, (e.g., backup, restore, snapshot,recovery, log record manipulation, and/or various space managementoperations) may be offloaded from the database engine to the storagelayer and distributed across multiple nodes and storage devices. Forexample, in some embodiments, rather than the database engine applyingchanges to database tables (or data pages thereof) and then sending themodified data pages to the storage layer, the application of changes tothe stored database tables (and data pages thereof) may be theresponsibility of the storage layer itself. In such embodiments, redolog records, rather than modified data pages, may be sent to the storagelayer, after which redo processing (e.g., the application of the redolog records) may be performed somewhat lazily and in a distributedmanner (e.g., by a background process). In some embodiments, crashrecovery (e.g., the rebuilding of data pages from stored redo logrecords) may also be performed by the storage layer and may also beperformed by a distributed (and, in some cases, lazy) backgroundprocess.

In some embodiments, because only redo logs (and not modified datapages) are sent to the storage layer, there may be much less networktraffic between the database tier and the storage layer than in existingdatabase systems. In some embodiments, each redo log may be on the orderof one-tenth the size of the corresponding data page for which itspecifies a change. Note that requests sent from the database tier andthe distributed storage system may be asynchronous and that multiplesuch requests may be in flight at a time.

In general, after being given a piece of data, a primary requirement ofa database is that it can eventually give that piece of data back. To dothis, the database may include several different components (or tiers),each of which performs a different function. For example, a traditionaldatabase may be thought of as having three tiers: a first tier forperforming query parsing, optimization and execution; a second tier forproviding transactionality, recovery, and durability; and a third tierthat provides storage, either on locally attached disks or onnetwork-attached storage. As noted above, previous attempts to scale atraditional database have typically involved replicating all three tiersof the database and distributing those replicated database instancesacross multiple machines.

In some embodiments, the systems described herein may partitionfunctionality of a database system differently than in a traditionaldatabase, and may distribute only a subset of the functional components(rather than a complete database instance) across multiple machines inorder to implement scaling. For example, in some embodiments, aclient-facing tier may be configured to receive a request specifyingwhat data is to be stored or retrieved, but not how to store or retrievethe data. This tier may perform request parsing and/or optimization(e.g., SQL parsing and optimization), while another tier may beresponsible for query execution. In some embodiments, a third tier maybe responsible for providing transactionality and consistency ofresults. For example, this tier may be configured to enforce some of theso-called ACID properties, in particular, the Atomicity of transactionsthat target the database, maintaining Consistency within the database,and ensuring Isolation between the transactions that target thedatabase. In some embodiments, a fourth tier may then be responsible forproviding Durability of the stored data in the presence of various sortsof faults. For example, this tier may be responsible for change logging,recovery from a database crash, managing access to the underlyingstorage volumes and/or space management in the underlying storagevolumes.

Turning now to the figures, FIG. 1 is a block diagram illustratingvarious components of a database software stack, according to oneembodiment. As illustrated in this example, a database instance mayinclude multiple functional components (or layers), each of whichprovides a portion of the functionality of the database instance. Inthis example, database instance 100 includes a query parsing and queryoptimization layer (shown as 110), a query execution layer (shown as120), a transactionality and consistency management layer (shown as130), and a durability and space management layer (shown as 140). Asnoted above, in some existing database systems, scaling a databaseinstance may involve duplicating the entire database instance one ormore times (including all of the layers illustrated in FIG. 1), and thenadding glue logic to stitch them together. In some embodiments, thesystems described herein may instead offload the functionality ofdurability and space management layer 140 from the database tier to aseparate storage layer, and may distribute that functionality acrossmultiple storage nodes in the storage layer.

In some embodiments, the database systems described herein may retainmuch of the structure of the upper half of the database instanceillustrated in FIG. 1, but may redistribute responsibility for at leastportions of the backup, restore, snapshot, recovery, and/or variousspace management operations to the storage tier. Redistributingfunctionality in this manner and tightly coupling log processing betweenthe database tier and the storage tier may improve performance, increaseavailability and reduce costs, when compared to previous approaches toproviding a scalable database. For example, network and input/outputbandwidth requirements may be reduced, since only redo log records(which are much smaller in size than the actual data pages) may beshipped across nodes or persisted within the latency path of writeoperations. In addition, the generation of data pages can be doneindependently in the background on each storage node (as foregroundprocessing allows), without blocking incoming write operations. In someembodiments, the use of log-structured, non-overwrite storage may allowbackup, restore, snapshots, point-in-time recovery, and volume growthoperations to be performed more efficiently, e.g., by using metadatamanipulation rather than movement or copying of a data page. In someembodiments, the storage layer may also assume the responsibility forthe replication of data stored on behalf of clients (and/or metadataassociated with that data, such as redo log records) across multiplestorage nodes. For example, data (and/or metadata) may be replicatedlocally (e.g., within a single “availability zone” in which a collectionof storage nodes executes on its own physically distinct, independentinfrastructure) and/or across availability zones in a single region orin different regions.

In various embodiments, the database systems described herein maysupport a standard or custom application programming interface (API) fora variety of database operations. For example, the API may supportoperations for creating a database, creating a table, altering a table,creating a user, dropping a user, inserting one or more rows in a table,copying values, selecting data from within a table (e.g., querying atable), canceling or aborting a query, creating a snapshot, and/or otheroperations.

In some embodiments, the database tier of a database instance mayinclude a database engine head node server that receives read and/orwrite requests from various client programs (e.g., applications) and/orsubscribers (users), then parses them and develops an execution plan tocarry out the associated database operation(s). For example, thedatabase engine head node may develop the series of steps necessary toobtain results for complex queries and joins. In some embodiments, thedatabase engine head node may manage communications between the databasetier of the database system and clients/subscribers, as well ascommunications between the database tier and a separate distributeddatabase-optimized storage system.

In some embodiments, the database engine head node may be responsiblefor receiving SQL requests from end clients through a JDBC or ODBCinterface and for performing SQL processing and transaction management(which may include locking) locally. However, rather than generatingdata pages locally, the database engine head node (or various componentsthereof) may generate redo log records and may ship them to theappropriate nodes of a separate distributed storage system. In someembodiments, a client-side driver for the distributed storage system maybe hosted on the database engine head node and may be responsible forrouting redo log records to the storage system node (or nodes) thatstore the segments (or data pages thereof) to which those redo logrecords are directed. For example, in some embodiments, each segment maybe mirrored (or otherwise made durable) on multiple storage system nodesthat form a protection group. In such embodiments, the client-sidedriver may keep track of the nodes on which each segment is stored andmay route redo logs to all of the nodes on which a segment is stored(e.g., asynchronously and in parallel, at substantially the same time),when a client request is received. As soon as the client-side driverreceives an acknowledgement back from a write quorum of the storagenodes in the protection group (which may indicate that the redo logrecord has been written to the storage node), it may send anacknowledgement of the requested change to the database tier (e.g., tothe database engine head node). For example, in embodiments in whichdata is made durable through the use of protection groups, the databaseengine head node may not be able to commit a transaction until andunless the client-side driver receives a reply from enough storage nodeinstances to constitute a write quorum. Similarly, for a read requestdirected to a particular segment, the client-side driver may route theread request to all of the nodes on which the segment is stored (e.g.,asynchronously and in parallel, at substantially the same time). As soonas the client-side driver receives the requested data from a read quorumof the storage nodes in the protection group, it may return therequested data to the database tier (e.g., to the database engine headnode).

In some embodiments, the database tier (or more specifically, thedatabase engine head node) may include a cache in which recentlyaccessed data pages are held temporarily. In such embodiments, if awrite request is received that targets a data page held in such a cache,in addition to shipping a corresponding redo log record to the storagelayer, the database engine may apply the change to the copy of the datapage held in its cache. However, unlike in other database systems, adata page held in this cache may not ever be flushed to the storagelayer, and it may be discarded at any time (e.g., at any time after theredo log record for a write request that was most recently applied tothe cached copy has been sent to the storage layer and acknowledged).The cache may implement any of various locking mechanisms to controlaccess to the cache by at most one writer (or multiple readers) at atime, in different embodiments. Note, however, that in embodiments thatinclude such a cache, the cache may not be distributed across multiplenodes, but may exist only on the database engine head node for a givendatabase instance. Therefore, there may be no cache coherency orconsistency issues to manage.

In some embodiments, the database tier may support the use ofsynchronous or asynchronous read replicas in the system, e.g., read-onlycopies of data on different nodes of the database tier to which readrequests can be routed. In such embodiments, if the database engine headnode for a given database table receives a read request directed to aparticular data page, it may route the request to any one (or aparticular one) of these read-only copies. In some embodiments, theclient-side driver in the database engine head node may be configured tonotify these other nodes about updates and/or invalidations to cacheddata pages (e.g., in order to prompt them to invalidate their caches,after which they may request updated copies of updated data pages fromthe storage layer).

In some embodiments, the client-side driver running on the databaseengine head node may expose a private interface to the storage tier. Insome embodiments, it may also expose a traditional iSCSI interface toone or more other components (e.g., other database engines or virtualcomputing services components). In some embodiments, storage for adatabase instance in the storage tier may be modeled as a single volumethat can grow in size without limits, and that can have an unlimitednumber of IOPS associated with it. When a volume is created, it may becreated with a specific size, with a specific availability/durabilitycharacteristic (e.g., specifying how it is replicated), and/or with anIOPS rate associated with it (e.g., both peak and sustained). Forexample, in some embodiments, a variety of different durability modelsmay be supported, and users/subscribers may be able to specify, fortheir database tables, a number of replication copies, zones, or regionsand/or whether replication is synchronous or asynchronous based upontheir durability, performance and cost objectives.

In some embodiments, the client side driver may maintain metadata aboutthe volume and may directly send asynchronous requests to each of thestorage nodes necessary to fulfill read requests and write requestswithout requiring additional hops between storage nodes. For example, insome embodiments, in response to a request to make a change to adatabase table, the client-side driver may be configured to determinethe one or more nodes that are implementing the storage for the targeteddata page, and to route the redo log record(s) specifying that change tothose storage nodes. The storage nodes may then be responsible forapplying the change specified in the redo log record to the targeteddata page at some point in the future. As writes are acknowledged backto the client-side driver, the client-side driver may advance the pointat which the volume is durable and may acknowledge commits back to thedatabase tier. As previously noted, in some embodiments, the client-sidedriver may not ever send data pages to the storage node servers. Thismay not only reduce network traffic, but may also remove the need forthe checkpoint or background writer threads that constrainforeground-processing throughput in previous database systems.

In some embodiments, many read requests may be served by the databaseengine head node cache. However, write requests may require durability,since large-scale failure events may be too common to allow onlyin-memory replication. Therefore, the systems described herein may beconfigured to minimize the cost of the redo log record write operationsthat are in the foreground latency path by implementing data storage inthe storage tier as two regions: a small append-only log-structuredregion into which redo log records are written when they are receivedfrom the database tier, and a larger region in which log records arecoalesced together to create new versions of data pages in thebackground. In some embodiments, an in-memory structure may bemaintained for each data page that points to the last redo log recordfor that page, backward chaining log records until an instantiated datablock is referenced. This approach may provide good performance formixed read-write workloads, including in applications in which reads arelargely cached.

In some embodiments, because accesses to the log-structured data storagefor the redo log records may consist of a series of sequentialinput/output operations (rather than random input/output operations),the changes being made may be tightly packed together. It should also benoted that, in contrast to existing systems in which each change to adata page results in two input/output operations to persistent datastorage (one for the redo log and one for the modified data pageitself), in some embodiments, the systems described herein may avoidthis “write amplification” by coalescing data pages at the storage nodesof the distributed storage system based on receipt of the redo logrecords.

As previously noted, in some embodiments, the storage tier of thedatabase system may be responsible for taking database snapshots.However, because the storage tier implements log-structured storage,taking a snapshot of a data page (e.g., a data block) may includerecording a timestamp associated with the redo log record that was mostrecently applied to the data page/block (or a timestamp associated withthe most recent operation to coalesce multiple redo log records tocreate a new version of the data page/block), and preventing garbagecollection of the previous version of the page/block and any subsequentlog entries up to the recorded point in time. In such embodiments,taking a database snapshot may not require reading, copying, or writingthe data block, as would be required when employing an off-volume backupstrategy. In some embodiments, the space requirements for snapshots maybe minimal, since only modified data would require additional space,although user/subscribers may be able to choose how much additionalspace they want to keep for on-volume snapshots in addition to theactive data set. In different embodiments, snapshots may be discrete(e.g., each snapshot may provide access to all of the data in a datapage as of a specific point in time) or continuous (e.g., each snapshotmay provide access to all versions of the data that existing in a datapage between two points in time). In some embodiments, reverting to aprior snapshot may include recording a log record to indicate that allredo log records and data pages since that snapshot are invalid andgarbage collectable, and discarding all database cache entries after thesnapshot point. In such embodiments, no roll-forward may be requiredsince the storage system will, on a block-by-block basis, apply redo logrecords to data blocks as requested and in the background across allnodes, just as it does in normal forward read/write processing. Crashrecovery may thereby be made parallel and distributed across nodes.Additional details regarding snapshot creation, use, and/or manipulationis described at FIGS. 8 and 9.

One embodiment of a service system architecture that may be configuredto implement a web services-based database service is illustrated inFIG. 2. In the illustrated embodiment, a number of clients (shown asdatabase clients 250 a-250 n) may be configured to interact with a webservices platform 200 via a network 260. Web services platform 200 maybe configured to interface with one or more instances of a databaseservice 210, a distributed database-optimized storage service 220 and/orone or more other virtual computing services 230. It is noted that whereone or more instances of a given component may exist, reference to thatcomponent herein may be made in either the singular or the plural.However, usage of either form is not intended to preclude the other.

In various embodiments, the components illustrated in FIG. 2 may beimplemented directly within computer hardware, as instructions directlyor indirectly executable by computer hardware (e.g., a microprocessor orcomputer system), or using a combination of these techniques. Forexample, the components of FIG. 2 may be implemented by a system thatincludes a number of computing nodes (or simply, nodes), each of whichmay be similar to the computer system embodiment illustrated in FIG. 10and described below. In various embodiments, the functionality of agiven service system component (e.g., a component of the databaseservice or a component of the storage service) may be implemented by aparticular node or may be distributed across several nodes. In someembodiments, a given node may implement the functionality of more thanone service system component (e.g., more than one database servicesystem component).

Generally speaking, clients 250 may encompass any type of clientconfigurable to submit web services requests to web services platform200 via network 260, including requests for database services (e.g., arequest to generate a snapshot, etc.). For example, a given client 250may include a suitable version of a web browser, or may include aplug-in module or other type of code module configured to execute as anextension to or within an execution environment provided by a webbrowser. Alternatively, a client 250 (e.g., a database service client)may encompass an application such as a database application (or userinterface thereof), a media application, an office application or anyother application that may make use of persistent storage resources tostore and/or access one or more database tables. In some embodiments,such an application may include sufficient protocol support (e.g., for asuitable version of Hypertext Transfer Protocol (HTTP)) for generatingand processing web services requests without necessarily implementingfull browser support for all types of web-based data. That is, client250 may be an application configured to interact directly with webservices platform 200. In some embodiments, client 250 may be configuredto generate web services requests according to a Representational StateTransfer (REST)-style web services architecture, a document- ormessage-based web services architecture, or another suitable webservices architecture.

In some embodiments, a client 250 (e.g., a database service client) maybe configured to provide access to web services-based storage ofdatabase tables to other applications in a manner that is transparent tothose applications. For example, client 250 may be configured tointegrate with an operating system or file system to provide storage inaccordance with a suitable variant of the storage models describedherein. However, the operating system or file system may present adifferent storage interface to applications, such as a conventional filesystem hierarchy of files, directories and/or folders. In such anembodiment, applications may not need to be modified to make use of thestorage system service model of FIG. 1. Instead, the details ofinterfacing to Web services platform 200 may be coordinated by client250 and the operating system or file system on behalf of applicationsexecuting within the operating system environment.

Clients 250 may convey web services requests (e.g., a snapshot request,parameters of a snapshot request, read request, restore a snapshot,etc.) to and receive responses from web services platform 200 vianetwork 260. In various embodiments, network 260 may encompass anysuitable combination of networking hardware and protocols necessary toestablish web-based communications between clients 250 and platform 200.For example, network 260 may generally encompass the varioustelecommunications networks and service providers that collectivelyimplement the Internet. Network 260 may also include private networkssuch as local area networks (LANs) or wide area networks (WANs) as wellas public or private wireless networks. For example, both a given client250 and web services platform 200 may be respectively provisioned withinenterprises having their own internal networks. In such an embodiment,network 260 may include the hardware (e.g., modems, routers, switches,load balancers, proxy servers, etc.) and software (e.g., protocolstacks, accounting software, firewall/security software, etc.) necessaryto establish a networking link between given client 250 and the Internetas well as between the Internet and web services platform 200. It isnoted that in some embodiments, clients 250 may communicate with webservices platform 200 using a private network rather than the publicInternet. For example, clients 250 may be provisioned within the sameenterprise as a database service system (e.g., a system that implementsdatabase service 210 and/or distributed database-optimized storageservice 220). In such a case, clients 250 may communicate with platform200 entirely through a private network 260 (e.g., a LAN or WAN that mayuse Internet-based communication protocols but which is not publiclyaccessible).

Generally speaking, web services platform 200 may be configured toimplement one or more service endpoints configured to receive andprocess web services requests, such as requests to access data pages (orrecords thereof). For example, web services platform 200 may includehardware and/or software configured to implement a particular endpoint,such that an HTTP-based web services request directed to that endpointis properly received and processed. In one embodiment, web servicesplatform 200 may be implemented as a server system configured to receiveweb services requests from clients 250 and to forward them to componentsof a system that implements database service 210, distributeddatabase-optimized storage service 220 and/or another virtual computingservice 230 for processing. In other embodiments, web services platform200 may be configured as a number of distinct systems (e.g., in acluster topology) implementing load balancing and other requestmanagement features configured to dynamically manage large-scale webservices request processing loads. In various embodiments, web servicesplatform 200 may be configured to support REST-style or document-based(e.g., SOAP-based) types of web services requests.

In addition to functioning as an addressable endpoint for clients' webservices requests, in some embodiments, web services platform 200 mayimplement various client management features. For example, platform 200may coordinate the metering and accounting of client usage of webservices, including storage resources, such as by tracking theidentities of requesting clients 250, the number and/or frequency ofclient requests, the size of data tables (or records thereof) stored orretrieved on behalf of clients 250, overall storage bandwidth used byclients 250, class of storage requested by clients 250, or any othermeasurable client usage parameter. Platform 200 may also implementfinancial accounting and billing systems, or may maintain a database ofusage data that may be queried and processed by external systems forreporting and billing of client usage activity. In certain embodiments,platform 200 may be configured to collect, monitor and/or aggregate avariety of storage service system operational metrics, such as metricsreflecting the rates and types of requests received from clients 250,bandwidth utilized by such requests, system processing latency for suchrequests, system component utilization (e.g., network bandwidth and/orstorage utilization within the storage service system), rates and typesof errors resulting from requests, characteristics of stored andrequested data pages or records thereof (e.g., size, data type, etc.),or any other suitable metrics. In some embodiments such metrics may beused by system administrators to tune and maintain system components,while in other embodiments such metrics (or relevant portions of suchmetrics) may be exposed to clients 250 to enable such clients to monitortheir usage of database service 210, distributed database-optimizedstorage service 220 and/or another virtual computing service 230 (or theunderlying systems that implement those services).

In some embodiments, platform 200 may also implement user authenticationand access control procedures. For example, for a given web servicesrequest to access a particular database table, platform 200 may beconfigured to ascertain whether the client 250 associated with therequest is authorized to access the particular database table. Platform200 may determine such authorization by, for example, evaluating anidentity, password or other credential against credentials associatedwith the particular database table, or evaluating the requested accessto the particular database table against an access control list for theparticular database table. For example, if a client 250 does not havesufficient credentials to access the particular database table, platform200 may reject the corresponding web services request, for example byreturning a response to the requesting client 250 indicating an errorcondition. Various access control policies may be stored as records orlists of access control information by database service 210, distributeddatabase-optimized storage service 220 and/or other virtual computingservices 230.

It is noted that while web services platform 200 may represent theprimary interface through which clients 250 may access the features of adatabase system that implements database service 210, it need notrepresent the sole interface to such features. For example, an alternateAPI that may be distinct from a web services interface may be used toallow clients internal to the enterprise providing the database systemto bypass web services platform 200. Note that in many of the examplesdescribed herein, distributed database-optimized storage service 220 maybe internal to a computing system or an enterprise system that providesdatabase services to clients 250, and may not be exposed to externalclients (e.g., users or client applications). In such embodiments, theinternal “client” (e.g., database service 210) may access distributeddatabase-optimized storage service 220 over a local or private network,shown as the solid line between distributed database-optimized storageservice 220 and database service 210 (e.g., through an API directlybetween the systems that implement these services). In such embodiments,the use of distributed database-optimized storage service 220 in storingdatabase tables on behalf of clients 250 may be transparent to thoseclients. In other embodiments, distributed database-optimized storageservice 220 may be exposed to clients 250 through web services platform200 to provide storage of database tables or other information forapplications other than those that rely on database service 210 fordatabase management. This is illustrated in FIG. 2 by the dashed linebetween web services platform 200 and distributed database-optimizedstorage service 220. In such embodiments, clients of the distributeddatabase-optimized storage service 220 may access distributeddatabase-optimized storage service 220 via network 260 (e.g., over theInternet). In some embodiments, a virtual computing service 230 may beconfigured to receive storage services from distributeddatabase-optimized storage service 220 (e.g., through an API directlybetween the virtual computing service 230 and distributeddatabase-optimized storage service 220) to store objects used inperforming computing services 230 on behalf of a client 250. This isillustrated in FIG. 2 by the dashed line between virtual computingservice 230 and distributed database-optimized storage service 220. Insome cases, the accounting and/or credentialing services of platform 200may be unnecessary for internal clients such as administrative clientsor between service components within the same enterprise.

Note that in various embodiments, different storage policies may beimplemented by database service 210 and/or distributeddatabase-optimized storage service 220. Examples of such storagepolicies may include a durability policy (e.g., a policy indicating thenumber of instances of a database table (or data page thereof) that willbe stored and the number of different nodes on which they will bestored) and/or a load balancing policy (which may distribute databasetables, or data pages thereof, across different nodes, volumes and/ordisks in an attempt to equalize request traffic). In addition, differentstorage policies may be applied to different types of stored items byvarious one of the services. For example, in some embodiments,distributed database-optimized storage service 220 may implement ahigher durability for redo log records than for data pages.

FIG. 3 is a block diagram illustrating various components of a databasesystem that includes a database engine and a separate distributeddatabase storage service, according to one embodiment. In this example,database system 300 includes a respective database engine head node 320for each of several database tables and a distributed database-optimizedstorage service 310 (which may or may not be visible to the clients ofthe database system, shown as database clients 350 a-350 n). Asillustrated in this example, one or more of database clients 350 a-350 nmay access a database head node 320 (e.g., head node 320 a, head node320 b, or head node 320 c, each of which is a component of a respectivedatabase instance) via network 360 (e.g., these components may benetwork-addressable and accessible to the database clients 350 a-350 n).However, distributed database-optimized storage service 310, which maybe employed by the database system to store data pages of one or moredatabase tables (and redo log records and/or other metadata associatedtherewith) on behalf of database clients 350 a-350 n, and to performother functions of the database system as described herein, may or maynot be network-addressable and accessible to the storage clients 350a-350 n, in different embodiments. For example, in some embodiments,distributed database-optimized storage service 310 may perform variousstorage, access, change logging, recovery, log record manipulation,and/or space management operations in a manner that is invisible tostorage clients 350 a-350 n.

As previously noted, each database instance may include a singledatabase engine head node 320 that receives requests (e.g., a snapshotrequest, etc.) from various client programs (e.g., applications) and/orsubscribers (users), then parses them, optimizes them, and develops anexecution plan to carry out the associated database operation(s). In theexample illustrated in FIG. 3, a query parsing, optimization, andexecution component 305 of database engine head node 320 a may performthese functions for queries that are received from database client 350 aand that target the database instance of which database engine head node320 a is a component. In some embodiments, query parsing, optimization,and execution component 305 may return query responses to databaseclient 350 a, which may include write acknowledgements, requested datapages (or portions thereof), error messages, and or other responses, asappropriate. As illustrated in this example, database engine head node320 a may also include a client-side storage service driver 325, whichmay route read requests and/or redo log records to various storage nodeswithin distributed database-optimized storage service 310, receive writeacknowledgements from distributed database-optimized storage service310, receive requested data pages from distributed database-optimizedstorage service 310, and/or return data pages, error messages, or otherresponses to query parsing, optimization, and execution component 305(which may, in turn, return them to database client 350 a).

In this example, database engine head node 320 a includes a data pagecache 335, in which data pages that were recently accessed may betemporarily held. As illustrated in FIG. 3, database engine head node320 a may also include a transaction and consistency managementcomponent 330, which may be responsible for providing transactionalityand consistency in the database instance of which database engine headnode 320 a is a component. For example, this component may beresponsible for ensuring the Atomicity, Consistency, and Isolationproperties of the database instance and the transactions that aredirected that the database instance. As illustrated in FIG. 3, databaseengine head node 320 a may also include a transaction log 340 and anundo log 345, which may be employed by transaction and consistencymanagement component 330 to track the status of various transactions androll back any locally cached results of transactions that do not commit.

Note that each of the other database engine head nodes 320 illustratedin FIG. 3 (e.g., 320 b and 320 c) may include similar components and mayperform similar functions for queries received by one or more ofdatabase clients 350 a-350 n and directed to the respective databaseinstances of which it is a component.

In some embodiments, the distributed database-optimized storage systemsdescribed herein may organize data in various logical volumes, segments,and pages for storage on one or more storage nodes. For example, in someembodiments, each database table is represented by a logical volume, andeach logical volume is segmented over a collection of storage nodes.Each segment, which lives on a particular one of the storage nodes,contains a set of contiguous block addresses. In some embodiments, eachdata page is stored in a segment, such that each segment stores acollection of one or more data pages and a change log (also referred toas a redo log) (e.g., a log of redo log records) for each data page thatit stores. As described in detail herein, the storage nodes may beconfigured to receive redo log records (which may also be referred toherein as ULRs) and to coalesce them to create new versions of thecorresponding data pages and/or additional or replacement log records(e.g., lazily and/or in response to a request for a data page or adatabase crash). In some embodiments, data pages and/or change logs maybe mirrored across multiple storage nodes, according to a variableconfiguration (which may be specified by the client on whose behalf thedatabase table is being maintained in the database system). For example,in different embodiments, one, two, or three copies of the data orchange logs may be stored in each of one, two, or three differentavailability zones or regions, according to a default configuration, anapplication-specific durability preference, or a client-specifieddurability preference.

As used herein, the following terms may be used to describe theorganization of data by a distributed database-optimized storage system,according to various embodiments.

Volume: A volume is a logical concept representing a highly durable unitof storage that a user/client/application of the storage systemunderstands. More specifically, a volume is a distributed store thatappears to the user/client/application as a single consistent orderedlog of write operations to various user pages of a database table. Eachwrite operation may be encoded in a User Log Record (ULR), whichrepresents a logical, ordered mutation to the contents of a single userpage within the volume. As noted above, a ULR may also be referred toherein as a redo log record. Each ULR may include a unique identifier(e.g., a Logical Sequence Number (LSN), time stamp, etc.). Note that theunique identifier may be monotonically increasing and unique for aparticular one of the log records. Also note that gaps may exist in thesequence of identifiers assigned to log records. For example, in the LSNexample, LSNs 1, 4, 5, 6, and 9 may be assigned to five respective logrecords with LSNs 2, 3, 7, and 8 not being used. Each ULR may bepersisted to one or more synchronous segments in the distributed storethat form a Protection Group (PG), to provide high durability andavailability for the ULR. A volume may provide an LSN-type read/writeinterface for a variable-size contiguous range of bytes.

In some embodiments, a volume may consist of multiple extents, each madedurable through a protection group. In such embodiments, a volume mayrepresent a unit of storage composed of a mutable contiguous sequence ofVolume Extents. Reads and writes that are directed to a volume may bemapped into corresponding reads and writes to the constituent volumeextents. In some embodiments, the size of a volume may be changed byadding or removing volume extents from the end of the volume.

Segment: A segment is a limited-durability unit of storage assigned to asingle storage node. More specifically, a segment provides limitedbest-effort durability (e.g., a persistent, but non-redundant singlepoint of failure that is a storage node) for a specific fixed-size byterange of data. This data may in some cases be a mirror ofuser-addressable data, or it may be other data, such as volume metadataor erasure coded bits, in various embodiments. A given segment may liveon exactly one storage node. Within a storage node, multiple segmentsmay live on each SSD, and each segment may be restricted to one SSD(e.g., a segment may not span across multiple SSDs). In someembodiments, a segment may not be required to occupy a contiguous regionon an SSD; rather there may be an allocation map in each SSD describingthe areas that are owned by each of the segments. As noted above, aprotection group may consist of multiple segments spread across multiplestorage nodes. In some embodiments, a segment may provide an LSN-typeread/write interface for a fixed-size contiguous range of bytes (wherethe size is defined at creation). In some embodiments, each segment maybe identified by a Segment UUID (e.g., a universally unique identifierof the segment).

Storage page: A storage page is a block of memory, generally of fixedsize. In some embodiments, each page is a block of memory (e.g., ofvirtual memory, disk, or other physical memory) of a size defined by theoperating system, and may also be referred to herein by the term “datablock”. More specifically, a storage page may be a set of contiguoussectors. It may serve as the unit of allocation in SSDs, as well as theunit in log pages for which there is a header and metadata. In someembodiments, and in the context of the database systems describedherein, the term “page” or “storage page” may refer to a similar blockof a size defined by the database configuration, which may typically amultiple of 2, such as 4096, 8192, 16384, or 32768 bytes.

Log page: A log page is a type of storage page that is used to store logrecords (e.g., redo log records or undo log records). In someembodiments, log pages may be identical in size to storage pages. Eachlog page may include a header containing metadata about that log page,e.g., metadata identifying the segment to which it belongs. Note that alog page is a unit of organization and may not necessarily be the unitof data included in write operations. For example, in some embodiments,during normal forward processing, write operations may write to the tailof the log one sector at a time.

Log Records: Log records (e.g., the individual elements of a log page)may be of several different classes. For example, User Log Records(ULRs), which are created and understood by users/clients/applicationsof the storage system, may be used to indicate changes to user data in avolume. Control Log Records (CLRs), which are generated by the storagesystem, may contain control information used to keep track of metadatasuch as the current unconditional volume durable LSN (VDL). Null LogRecords (NLRs) may in some embodiments be used as padding to fill inunused space in a log sector or log page. In some embodiments, there maybe various types of log records within each of these classes, and thetype of a log record may correspond to a function that needs to beinvoked to interpret the log record. For example, one type may representall the data of a user page in compressed format using a specificcompression format; a second type may represent new values for a byterange within a user page; a third type may represent an incrementoperation to a sequence of bytes interpreted as an integer; and a fourthtype may represent copying one byte range to another location within thepage. In some embodiments, log record types may be identified by GUIDs(rather than by integers or enums), which may simplify versioning anddevelopment, especially for ULRs.

Payload: The payload of a log record is the data or parameter valuesthat are specific to the log record or to log records of a particulartype. For example, in some embodiments, there may be a set of parametersor attributes that most (or all) log records include, and that thestorage system itself understands. These attributes may be part of acommon log record header/structure, which may be relatively smallcompared to the sector size. In addition, most log records may includeadditional parameters or data specific to that log record type, and thisadditional information may be considered the payload of that log record.In some embodiments, if the payload for a particular ULR is larger thanthe user page size, it may be replaced by an absolute ULR (an AULR)whose payload includes all the data for the user page. This may enablethe storage system to enforce an upper limit on the size of the payloadfor ULRs that is equal to the size of user pages.

Note that when storing log records in the segment log, the payload maybe stored along with the log header, in some embodiments. In otherembodiments, the payload may be stored in a separate location, andpointers to the location at which that payload is stored may be storedwith the log header. In still other embodiments, a portion of thepayload may be stored in the header, and the remainder of the payloadmay be stored in a separate location. If the entire payload is storedwith the log header, this may be referred to as in-band storage;otherwise the storage may be referred to as being out-of-band. In someembodiments, the payloads of most large AULRs may be stored out-of-bandin the cold zone of log (which is described below).

User pages: User pages are the byte ranges (of a fixed size) andalignments thereof for a particular volume that are visible tousers/clients of the storage system. User pages are a logical concept,and the bytes in particular user pages may or not be stored in anystorage page as-is. The size of the user pages for a particular volumemay be independent of the storage page size for that volume. In someembodiments, the user page size may be configurable per volume, anddifferent segments on a storage node may have different user page sizes.In some embodiments, user page sizes may be constrained to be a multipleof the sector size (e.g., 4 KB), and may have an upper limit (e.g., 64KB). The storage page size, on the other hand, may be fixed for anentire storage node and may not change unless there is a change to theunderlying hardware.

Data page: A data page is a type of storage page that is used to storeuser page data in compressed form. In some embodiments every piece ofdata stored in a data page is associated with a log record, and each logrecord may include a pointer to a sector within a data page (alsoreferred to as a data sector). In some embodiments, data pages may notinclude any embedded metadata other than that provided by each sector.There may be no relationship between the sectors in a data page.Instead, the organization into pages may exist only as an expression ofthe granularity of the allocation of data to a segment.

Storage node: A storage node is a single virtual machine that on whichstorage node server code is deployed. Each storage node may containmultiple locally attached SSDs, and may provide a network API for accessto one or more segments. In some embodiments, various nodes may be on anactive list or on a degraded list (e.g., if they are slow to respond orare otherwise impaired, but are not completely unusable). In someembodiments, the client-side driver may assist in (or be responsiblefor) classifying nodes as active or degraded, for determining if andwhen they should be replaced, and/or for determining when and how toredistribute data among various nodes, based on observed performance.

SSD: As referred to herein, the term “SSD” may refer to a local blockstorage volume as seen by the storage node, regardless of the type ofstorage employed by that storage volume, e.g., disk, a solid-statedrive, a battery-backed RAM, an NVMRAM device (e.g., one or moreNVDIMMs), or another type of persistent storage device. An SSD is notnecessarily mapped directly to hardware. For example, a singlesolid-state storage device might be broken up into multiple localvolumes where each volume is split into and striped across multiplesegments, and/or a single drive may be broken up into multiple volumessimply for ease of management, in different embodiments. In someembodiments, each SSD may store an allocation map at a single fixedlocation. This map may indicate which storage pages that are owned byparticular segments, and which of these pages are log pages (as opposedto data pages). In some embodiments, storage pages may be pre-allocatedto each segment so that forward processing may not need to wait forallocation. Any changes to the allocation map may need to be madedurable before newly allocated storage pages are used by the segments.

One embodiment of a distributed database-optimized storage system isillustrated by the block diagram in FIG. 4. In this example, a databasesystem 400 includes a distributed database-optimized storage system 410,which communicates with a database engine head node 420 overinterconnect 460. As in the example illustrated in FIG. 3, databaseengine head node 420 may include a client-side storage service driver425. In this example, distributed database-optimized storage system 410includes multiple storage system server nodes (including those shown as430, 440, and 450), each of which includes storage for data pages andredo logs for the segment(s) it stores, and hardware and/or softwareconfigured to perform various segment management functions. For example,each storage system server node may include hardware and/or softwareconfigured to perform at least a portion of any or all of the followingoperations: replication (locally, e.g., within the storage node),coalescing of redo logs to generate data pages, snapshots (e.g.,creating, restoration, deletion, etc.), log management (e.g.,manipulating log records), crash recovery, and/or space management(e.g., for a segment). Each storage system server node may also havemultiple attached storage devices (e.g., SSDs) on which data blocks maybe stored on behalf of clients (e.g., users, client applications, and/ordatabase service subscribers).

In the example illustrated in FIG. 4, storage system server node 430includes data page(s) 433, segment redo log(s) 435, segment managementfunctions 437, and attached SSDs 471-478. Again note that the label“SSD” may or may not refer to a solid-state drive, but may moregenerally refer to a local block storage volume, regardless of itsunderlying hardware. Similarly, storage system server node 440 includesdata page(s) 443, segment redo log(s) 445, segment management functions447, and attached SSDs 481-488; and storage system server node 450includes data page(s) 453, segment redo log(s) 455, segment managementfunctions 457, and attached SSDs 491-498.

As previously noted, in some embodiments, a sector is the unit ofalignment on an SSD and may be the maximum size on an SSD that can bewritten without the risk that the write will only be partiallycompleted. For example, the sector size for various solid-state drivesand spinning media may be 4 KB. In some embodiments of the distributeddatabase-optimized storage systems described herein, each and everysector may include have a 64-bit (8 byte) CRC at the beginning of thesector, regardless of the higher-level entity of which the sector is apart. In such embodiments, this CRC (which may be validated every time asector is read from SSD) may be used in detecting corruptions. In someembodiments, each and every sector may also include a “sector type” bytewhose value identifies the sector as a log sector, a data sector, or anuninitialized sector. For example, in some embodiments, a sector typebyte value of 0 may indicate that the sector is uninitialized.

In some embodiments, each of the storage system server nodes in thedistributed database-optimized storage system may implement a set ofprocesses running on the node server's operating system that managecommunication with the database engine head node, e.g., to receive redologs, send back data pages, etc. In some embodiments, all data blockswritten to the distributed database-optimized storage system may bebacked up to long-term and/or archival storage (e.g., in a remotekey-value durable backup storage system).

FIG. 5 is a block diagram illustrating the use of a separate distributeddatabase-optimized storage system in a database system, according to oneembodiment. In this example, one or more client processes 510 may storedata to one or more database tables maintained by a database system thatincludes a database engine 520 and a distributed database-optimizedstorage system 530. In the example illustrated in FIG. 5, databaseengine 520 includes database tier components 560 and client-side driver540 (which serves as the interface between distributeddatabase-optimized storage system 530 and database tier components 560).In some embodiments, database tier components 560 may perform functionssuch as those performed by query parsing, optimization and executioncomponent 305 and transaction and consistency management component 330of FIG. 3, and/or may store data pages, transaction logs and/or undologs (such as those stored by data page cache 335, transaction log 340and undo log 345 of FIG. 3).

In this example, one or more client processes 510 may send databasequery requests 515 (which may include read and/or write requeststargeting data stored on one or more of the storage nodes 535 a-535 n)to database tier components 560, and may receive database queryresponses 517 from database tier components 560 (e.g., responses thatinclude write acknowledgements and/or requested data). Each databasequery request 515 that includes a request to write to a data page may beparsed and optimized to generate one or more write record requests 541,which may be sent to client-side driver 540 for subsequent routing todistributed database-optimized storage system 530. In this example,client-side driver 540 may generate one or more redo log records 531corresponding to each write record request 541, and may send them tospecific ones of the storage nodes 535 of distributed database-optimizedstorage system 530. Distributed database-optimized storage system 530may return a corresponding write acknowledgement 523 for each redo logrecord 531 to database engine 520 (specifically to client-side driver540). Client-side driver 540 may pass these write acknowledgements todatabase tier components 560 (as write responses 542), which may thensend corresponding responses (e.g., write acknowledgements) to one ormore client processes 510 as one of database query responses 517.

In this example, each database query request 515 that includes a requestto read a data page may be parsed and optimized to generate one or moreread record requests 543, which may be sent to client-side driver 540for subsequent routing to distributed database-optimized storage system530. In this example, client-side driver 540 may send these requests tospecific ones of the storage nodes 535 of distributed database-optimizedstorage system 530, and distributed database-optimized storage system530 may return the requested data pages 533 to database engine 520(specifically to client-side driver 540). Client-side driver 540 maysend the returned data pages to the database tier components 560 asreturn data records 544, and database tier components 560 may then sendthe data pages to one or more client processes 510 as database queryresponses 517.

In some embodiments, various error and/or data loss messages 534 may besent from distributed database-optimized storage system 530 to databaseengine 520 (specifically to client-side driver 540). These messages maybe passed from client-side driver 540 to database tier components 560 aserror and/or loss reporting messages 545, and then to one or more clientprocesses 510 along with (or instead of) a database query response 517.

In some embodiments, the APIs 531-534 of distributed database-optimizedstorage system 530 and the APIs 541-545 of client-side driver 540 mayexpose the functionality of the distributed database-optimized storagesystem 530 to database engine 520 as if database engine 520 were aclient of distributed database-optimized storage system 530. Forexample, database engine 520 (through client-side driver 540) may writeredo log records or request data pages through these APIs to perform (orfacilitate the performance of) various operations of the database systemimplemented by the combination of database engine 520 and distributeddatabase-optimized storage system 530 (e.g., storage, access, changelogging, recovery, and/or space management operations). As illustratedin FIG. 5, distributed database-optimized storage system 530 may storedata blocks on storage nodes 535 a-535 n, each of which may havemultiple attached SSDs. In some embodiments, distributeddatabase-optimized storage system 530 may provide high durability forstored data block through the application of various types of redundancyschemes.

Note that in various embodiments, the API calls and responses betweendatabase engine 520 and distributed database-optimized storage system530 (e.g., APIs 531-534) and/or the API calls and responses betweenclient-side driver 540 and database tier components 560 (e.g., APIs541-545) in FIG. 5 may be performed over a secure proxy connection(e.g., one managed by a gateway control plane), or may be performed overthe public network or, alternatively, over a private channel such as avirtual private network (VPN) connection. These and other APIs to and/orbetween components of the database systems described herein may beimplemented according to different technologies, including, but notlimited to, Simple Object Access Protocol (SOAP) technology andRepresentational state transfer (REST) technology. For example, theseAPIs may be, but are not necessarily, implemented as SOAP APIs orRESTful APIs. SOAP is a protocol for exchanging information in thecontext of Web-based services. REST is an architectural style fordistributed hypermedia systems. A RESTful API (which may also bereferred to as a RESTful web service) is a web service API implementedusing HTTP and REST technology. The APIs described herein may in someembodiments be wrapped with client libraries in various languages,including, but not limited to, C, C++, Java, C# and Perl to supportintegration with database engine 520 and/or distributeddatabase-optimized storage system 530.

As noted above, in some embodiments, the functional components of adatabase system may be partitioned between those that are performed bythe database engine and those that are performed in a separate,distributed, database-optimized storage system. In one specific example,in response to receiving a request from a client process (or a threadthereof) to insert something into a database table (e.g., to update asingle data block by adding a record to that data block), one or morecomponents of the database engine head node may perform query parsing,optimization, and execution, and may send each portion of the query to atransaction and consistency management component. The transaction andconsistency management component may ensure that no other client process(or thread thereof) is trying to modify the same row at the same time.For example, the transaction and consistency management component may beresponsible for ensuring that this change is performed atomically,consistently, durably, and in an isolated manner in the database. Forexample, the transaction and consistency management component may worktogether with the client-side storage service driver of the databaseengine head node to generate a redo log record to be sent to one of thenodes in the distributed database-optimized storage service and to sendit to the distributed database-optimized storage service (along withother redo logs generated in response to other client requests) in anorder and/or with timing that ensures the ACID properties are met forthis transaction. Upon receiving the redo log record (which may also bereferred to as an update record), the corresponding storage node mayupdate the data block, and may update a redo log for the data block(e.g., a record of all changes directed to the data block). In someembodiments, the database engine may be responsible for generating anundo log record for this change, and may also be responsible forgenerating a redo log record for the undo log both of which may be usedlocally (in the database tier) for ensuring transactionality. However,unlike in traditional database systems, the systems described herein mayshift the responsibility for applying changes to data blocks to thestorage system (rather than applying them at the database tier andshipping the modified data blocks to the storage system). Moreover, asdescribed herein at FIGS. 8-9, in various embodiments, snapshotoperations and/or log manipulations may be performed by the storagesystem as well.

A variety of different allocation models may be implemented for an SSD,in different embodiments. For example, in some embodiments, log entrypages and physical application pages may be allocated from a single heapof pages associated with an SSD device. This approach may have theadvantage of leaving the relative amount of storage consumed by logpages and data pages to remain unspecified and to adapt automatically tousage. It may also have the advantage of allowing pages to remainunprepared until they are used, and repurposed at will withoutpreparation. In other embodiments, an allocation model may partition thestorage device into separate spaces for log entries and data pages. Oncesuch allocation model is illustrated by the block diagram in FIG. 6 anddescribed below.

FIG. 6 is a block diagram illustrating how data and metadata may bestored on a given storage node (or persistent storage device) of adistributed database-optimized storage system, according to oneembodiment. In this example, SSD storage space 600 stores an SSD headerand other fixed metadata in the portion of the space labeled 610. Itstores log pages in the portion of the space labeled 620, and includes aspace labeled 630 that is initialized and reserved for additional logpages. One portion of SSD storage space 600 (shown as 640) isinitialized, but unassigned, and another portion of the space (shown as650) is uninitialized and unassigned. Finally, the portion of SSDstorage space 600 labeled 660 stores data pages.

In this example, the first usable log page slot is noted as 615, and thelast used log page slot (ephemeral) is noted as 625. The last reservedlog page slot is noted as 635, and the last usable log page slot isnoted as 645. In this example, the first used data page slot (ephemeral)is noted as 665. In some embodiments, the positions of each of theseelements (615, 625, 635, 645, and 665) within SSD storage space 600 maybe identified by a respective pointer.

In allocation approach illustrated in FIG. 6, valid log pages may bepacked into the beginning of the flat storage space. Holes that open updue to log pages being freed may be reused before additional log pageslots farther into the address space are used. For example, in the worstcase, the first n log page slots contain valid log data, where n is thelargest number of valid log pages that have ever simultaneously existed.In this example, valid data pages may be packed into the end of the flatstorage space. Holes that open up due to data pages being freed may bereused before additional data page slots lower in the address space areused. For example, in the worst case, the last m data pages containvalid data, where m is the largest number of valid data pages that haveever simultaneously existed.

In some embodiments, before a log page slot can become part of thepotential set of valid log page entries, it must be initialized to avalue that cannot be confused for a valid future log entry page. This isimplicitly true for recycled log page slots, since a retired log pagehas enough metadata to never be confused for a new valid log page.However, when a storage device is first initialized, or when space isreclaimed that had potentially been used to store application datapages, the log page slots must be initialized before they are added tothe log page slot pool. In some embodiments, rebalancing/reclaiming logspace may be performed as a background task.

In the example illustrated in FIG. 6, the current log page slot poolincludes the area between the first usable log page slot (at 615) andthe last reserved log page slot (625). In some embodiments, this poolmay safely grow up to last usable log page slot (625) withoutre-initialization of new log page slots (e.g., by persisting an updateto the pointer that identifies the last reserved log page slot, 635). Inthis example, beyond the last usable log page slot (which is identifiedby pointer 645), the pool may grow up to the first used data page slot(which is identified by pointer 665) by persisting initialized log pageslots and persistently updating the pointer for the last usable log pageslot (645). In this example, the previously uninitialized and unassignedportion of the SSD storage space 600 shown as 650 may be pressed intoservice to store log pages. In some embodiments, the current log pageslot pool may be shrunk down to the position of the last used log pageslot (which is identified by pointer) by persisting an update to thepointer for the last reserved log page slot (635).

In the example illustrated in FIG. 6, the current data page slot poolincludes the area between the last usable log page slot (which isidentified by pointer 645) and the end of SSD storage space 600. In someembodiments, the data page pool may be safely grown to the positionidentified by the pointer to the last reserved log page slot (635) bypersisting an update to the pointer to the last usable log page slot(645). In this example, the previously initialized, but unassignedportion of the SSD storage space 600 shown as 640 may be pressed intoservice to store data pages. Beyond this, the pool may be safely grownto the position identified by the pointer to the last used log page slot(625) by persisting updates to the pointers for the last reserved logpage slot (635) and the last usable log page slot (645), effectivelyreassigning the portions of SSD storage space 600 shown as 630 and 640to store data pages, rather than log pages. In some embodiments, thedata page slot pool may be safely shrunk down to the position identifiedby the pointer to the first used data page slot (665) by initializingadditional log page slots and persisting an update to the pointer to thelast usable log page slot (645).

In embodiments that employ the allocation approach illustrated in FIG.6, page sizes for the log page pool and the data page pool may beselected independently, while still facilitating good packing behavior.In such embodiments, there may be no possibility of a valid log pagelinking to a spoofed log page formed by application data, and it may bepossible to distinguish between a corrupted log and a valid log tailthat links to an as-yet-unwritten next page. In embodiments that employthe allocation approach illustrated in FIG. 6, at startup, all of thelog page slots up to the position identified by the pointer to the lastreserved log page slot (635) may be rapidly and sequentially read, andthe entire log index may be reconstructed (including inferredlinking/ordering). In such embodiments, there may be no need forexplicit linking between log pages, since everything can be inferredfrom LSN sequencing constraints.

In some embodiments, a segment may consist of three main parts (orzones): one that contains a hot log, one that contains a cold log, andone that contains user page data. Zones are not necessarily contiguousregions of an SSD. Rather, they can be interspersed at the granularityof the storage page. In addition, there may be a root page for eachsegment that stores metadata about the segment and its properties. Forexample, the root page for a segment may store the user page size forthe segment, the number of user pages in the segment, the currentbeginning/head of the hot log zone (which may be recorded in the form ofa flush number), the volume epoch, and/or access control metadata.

In some embodiments, the hot log zone may accept new writes from theclient as they are received by the storage node. Both Delta User LogRecords (DULRs), which specify a change to a user/data page in the formof a delta from the previous version of the page, and Absolute User LogRecords (AULRs), which specify the contents of a complete user/datapage, may be written completely into the log. Log records may be addedto this zone in approximately the order they are received (e.g., theyare not sorted by LSN) and they can span across log pages. The logrecords may be self-describing, e.g., they may contain an indication oftheir own size. In some embodiments, no garbage collection is performedin this zone. Instead, space may be reclaimed by truncating from thebeginning of the log after all required log records have been copiedinto the cold log. Log sectors in the hot zone may be annotated with themost recent known unconditional VDL each time a sector is written.Conditional VDL CLRs may be written into the hot zone as they arereceived, but only the most recently written VDL CLR may be meaningful.

In some embodiments, every time a new log page is written, it may beassigned a flush number. The flush number may be written as part ofevery sector within each log page. Flush numbers may be used todetermine which log page was written later when comparing two log pages.

Flush numbers are monotonically increasing and scoped to an SSD (orstorage node). For example, a set of monotonically increasing flushnumbers is shared between all segments on an SSD (or all segments on astorage node).

In some embodiments, in the cold log zone, log records may be stored inincreasing order of their LSNs. In this zone, AULRs may not necessarilystore data in-line, depending on their size. For example, if they havelarge payloads, all or a portion of the payloads may be stored in thedata zone and they may point to where their data is stored in the datazone. In some embodiments, log pages in the cold log zone may be writtenone full page at a time, rather than sector-by-sector. Because log pagesin the cold zone are written a full page at a time, any log page in thecold zone for which the flush numbers in all sectors are not identicalmay be considered to be an incompletely written page and may be ignored.In some embodiments, in the cold log zone, DULRs may be able to spanacross log pages (up to a maximum of two log pages). However, AULRs maynot be able to span log sectors, e.g., so that a coalesce operation willbe able to replace a DULR with an AULR in a single atomic write.

In some embodiments, the cold log zone is populated by copying logrecords from the hot log zone. In such embodiments, only log recordswhose LSN is less than or equal to the current unconditional volumedurable LSN (VDL) may be eligible to be copied to the cold log zone.When moving log records from the hot log zone to the cold log zone, somelog records (such as many CLRs) may not need to be copied because theyare no longer necessary. In addition, some additional coalescing of userpages may be performed at this point, which may reduce the amount ofcopying required. In some embodiments, once a given hot zone log pagehas been completely written and is no longer the newest hot zone logpage, and all ULRs on the hot zone log page have been successfullycopied to the cold log zone, the hot zone log page may be freed andreused.

In some embodiments, garbage collection may be done in the cold log zoneto reclaim space occupied by obsolete log records, e.g., log recordsthat no longer need to be stored in the SSDs of the storage tier. Forexample, a log record may become obsolete when there is a subsequentAULR for the same user page and the version of the user page representedby the log record is not needed for retention on SSD. In someembodiments, a garbage collection process may reclaim space by mergingtwo or more adjacent log pages and replacing them with fewer new logpages containing all of the non-obsolete log records from the log pagesthat they are replacing. The new log pages may be assigned new flushnumbers that are larger than the flush numbers of the log pages they arereplacing. After the write of these new log pages is complete, thereplaced log pages may be added to the free page pool. Note that in someembodiments, there may not be any explicit chaining of log pages usingany pointers. Instead, the sequence of log pages may be implicitlydetermined by the flush numbers on those pages. Whenever multiple copiesof a log record are found, the log record present in the log page withhighest flush number may be considered to be valid and the others may beconsidered to be obsolete.

In some embodiments, e.g., because the granularity of space managedwithin a data zone (sector) may be different from the granularityoutside the data zone (storage page), there may be some fragmentation.In some embodiments, to keep this fragmentation under control, thesystem may keep track of the number of sectors used by each data page,may preferentially allocate from almost-full data pages, andpreferentially garbage collect almost-empty data pages (may requiremoving data to a new location if it is still relevant). Note that pagesallocated to a segment may in some embodiments be repurposed among thethree zones. For example, when a page that was allocated to a segment isfreed, it may remain associated with that segment for some period oftime and may subsequently be used in any of the three zones of thatsegment. The sector header of every sector may indicate the zone towhich the sector belongs. Once all sectors in a page are free, the pagemay be returned to a common free storage page pool that is shared acrosszones. This free storage page sharing may in some embodiments reduce (oravoid) fragmentation.

In some embodiments, the distributed database-optimized storage systemsdescribed herein may maintain various data structures in memory. Forexample, for each user page present in a segment, a user page table maystore a bit indicating whether or not this user page is “cleared” (i.e.,whether it includes all zeroes), the LSN of the latest log record fromthe cold log zone for the page, and an array/list of locations of alllog records from the hot log zone for page. For each log record, theuser page table may store the sector number, the offset of the logrecord within that sector, the number of sectors to read within that logpage, the sector number of a second log page (if the log record spanslog pages), and the number of sectors to read within that log page. Insome embodiments, the user page table may also store the LSNs of everylog record from the cold log zone and/or an array of sector numbers forthe payload of the latest AULR if it is in the cold log zone.

In some embodiments of the distributed database-optimized storagesystems described herein, an LSN index may be stored in memory. An LSNindex may map LSNs to log pages within the cold log zone. Given that logrecords in cold log zone are sorted, it may be to include one entry perlog page. However, in some embodiments, every non-obsolete LSN may bestored in the index and mapped to the corresponding sector numbers,offsets, and numbers of sectors for each log record.

In some embodiments of the distributed database-optimized storagesystems described herein, a log page table may be stored in memory, andthe log page table may be used during garbage collection of the cold logzone. For example, the log page table may identify which log records areobsolete (e.g., which log records can be garbage collected) and how muchfree space is available on each log page.

In the storage systems described herein, an extent may be a logicalconcept representing a highly durable unit of storage that can becombined with other extents (either concatenated or striped) torepresent a volume. Each extent may be made durable by membership in asingle protection group. An extent may provide an LSN-type read/writeinterface for a contiguous byte sub-range having a fixed size that isdefined at creation. Read/write operations to an extent may be mappedinto one or more appropriate segment read/write operations by thecontaining protection group. As used herein, the term “volume extent”may refer to an extent that is used to represent a specific sub-range ofbytes within a volume.

As noted above, a volume may consist of multiple extents, eachrepresented by a protection group consisting of one or more segments. Insome embodiments, log records directed to different extents may haveinterleaved LSNs. For changes to the volume to be durable up to aparticular LSN it may be necessary for all log records up to that LSN tobe durable, regardless of the extent to which they belong. In someembodiments, the client may keep track of outstanding log records thathave not yet been made durable, and once all ULRs up to a specific LSNare made durable, it may send a Volume Durable LSN (VDL) message to oneof the protection groups in the volume. The VDL may be written to allsynchronous mirror segments for the protection group. This is sometimesreferred to as an “Unconditional VDL” and it may be periodicallypersisted to various segments (or more specifically, to variousprotection groups) along with write activity happening on the segments.In some embodiments, the Unconditional VDL may be stored in log sectorheaders.

In various embodiments, the operations that may be performed on asegment may include writing a DULR or AULR received from a client (whichmay involve writing the DULR or AULR to the tail of the hot log zone andthen updating the user page table), reading a cold user page (which mayinvolve locating the data sectors of the user page and returning themwithout needing to apply any additional DULRs), reading a hot user page(which may involve locating the data sectors of the most recent AULR forthe user page and apply any subsequent DULRs to the user page beforereturning it), replacing DULRs with AULRs (which may involve coalescingDULRs for a user page to create an AULR that replaces the last DULR thatwas applied), manipulating the log records, etc. As described hereincoalescing is the process of applying DULRs to an earlier version of auser page to create a later version of the user page. Coalescing a userpage may help reduce read latency because (until another DULR iswritten) all DULRs written prior to coalescing may not need to be readand applied on demand. It may also help reclaim storage space by makingold AULRs and DULRs obsolete (provided there is no snapshot requiringthe log records to be present). In some embodiments, a coalescingoperation may include locating a most recent AULR and applying anysubsequent DULRs in sequence without skipping any of the DULRs. As notedabove, in some embodiments, coalescing may not be performed within thehot log zone. Instead, it may be performed within the cold log zone. Insome embodiments, coalescing may also be performed as log records arecopied from the hot log zone to the cold log zone.

In some embodiments, the decision to coalesce a user page may betriggered by the size of the pending DULR chain for the page (e.g., ifthe length of the DULR chain exceeds a pre-defined threshold for acoalescing operation, according to a system-wide, application-specificor client-specified policy)), or by the user page being read by aclient.

FIG. 7 is a block diagram illustrating an example configuration of adatabase volume 710, according to one embodiment. In this example, datacorresponding to each of various address ranges 715 (shown as addressranges 715 a-715 e) is stored as different segments 745 (shown assegments 745 a-745 n). More specifically, data corresponding to each ofvarious address ranges 715 may be organized into different extents(shown as extents 725 a-725 b, and extents 735 a-735 h), and variousones of these extents may be included in different protection groups 730(shown as 730 a-730 f), with or without striping (such as that shown asstripe set 720 a and stripe set 720 b). In this example, protectiongroup 1 illustrates the use of erasure coding. In this example,protection groups 2 and 3 and protection groups 6 and 7 representmirrored data sets of each other, while protection group 4 represents asingle-instance (non-redundant) data set. In this example, protectiongroup 8 represents a multi-tier protection group that combines otherprotection groups (e.g., this may represent a multi-region protectiongroup). In this example, stripe set 1 (720 a) and stripe set 2 (720 b)illustrates how extents (e.g., extents 725 a and 725 b) may be stripedinto a volume, in some embodiments.

More specifically, in this example, protection group 1 (730 a) includesextents a-c (735 a-735 c), which include data from ranges 1-3 (715 a-715c), respectively, and these extents are mapped to segments 1-4 (745a-745 d). Protection group 2 (730 b) includes extent d (735 d), whichincludes data striped from range 4 (715 d), and this extent is mapped tosegments 5-7 (745 e-745 g). Similarly, protection group 3 (730 c)includes extent e (735 e), which includes data striped from range 4 (715d), and is mapped to segments 8-9 (745 h-745 i); and protection group 4(730 d) includes extent f (735 f), which includes data striped fromrange 4 (715 d), and is mapped to segment 10 (745 j). In this example,protection group 6 (730 e) includes extent g (735 g), which includesdata striped from range 5 (715 e), and is mapped to segments 11-12 (745k-7451); and protection group 7 (730 f) includes extent h (735 h), whichalso includes data striped from range 5 (715 e), and is mapped tosegments 13-14 (745 m-745 n).

Turning now to FIG. 8, in various embodiments, database system 400 maybe configured to create, delete, modify, and/or otherwise use asnapshot. While the method of FIG. 8 may be described as being performedby various components of a log-structured storage system, such asdistributed database-optimized storage system 410 (e.g. storage systemserver node(s) 430, 440, 450, etc.), the method need not be performed byany specific component in some cases. For instance, in some cases, themethod of FIG. 8 may be performed by some other component or computersystem, according to some embodiments. Or, in some cases, components ofdatabase system 400 may be combined or exist in a different manner thanthat shown in the example of FIG. 4. In various embodiments, the methodof FIG. 8 may be performed by one or more computers of a distributeddatabase-optimized storage system, one of which is shown as the computersystem of FIG. 10. The method of FIG. 8 is shown as one exampleimplementation of a method for snapshot creation, deletion,modification, use, etc. In other implementations, the method of FIG. 8may include additional or fewer blocks than are shown.

At 810, a plurality of log records, each associated with a respectivechange to data stored/maintained by a database service, may bemaintained. In various embodiments, the changes, represented by logrecords, may be stored by storage system service node 430 of adistributed database-optimized storage system of a database service. Asdescribed herein, in one embodiment, the log records may be received, bydistributed database-optimized storage system, from a database enginehead node of the database service. In other embodiments, the log recordsmay be received from another component of the database service that isseparate from the distributed database-optimized storage system

In one embodiment, each log record may be associated with a respectiveidentifier, such as a sequentially ordered identifier (e.g. a logsequence number (“LSN”)), as described herein. The log records may beassociated with a respective LSN at the time they are received or thestorage system may assign an LSN to a given log record in the order inwhich it was received.

The data to which the plurality of log records corresponds may be asingle data page (e.g., of data page(s) 433, 443, or 453 of FIG. 4) or anumber of data pages. Consider a scenario in which the plurality of logrecords includes four log records having LSNs 1-4. In one example, eachof LSNs 1-4 may pertain to a data page A. Or, in another example, LSNs 1and 3 may pertain to data page A and LSNs 2 and 4 may pertain to datapage B. Note that, in the examples, each particular log record may beassociated with a single user/data page (e.g., LSN1-page A, LSN2-page B,etc.).

Note that in various embodiments, the log records may be stored in adistributed manner across the various nodes, such as storage systemserver nodes 430, 440, and 450 of FIG. 4. In some embodiments, a singlecopy of the log record may be stored at a single node, or a single copymay be stored at multiple nodes, among other examples. Continuing thefour log record example from above, the log record with LSN 1 may bestored at both of nodes 430 and 440, LSN 2 may be stored at node 430,and LSNs 3 and 4 may be stored at all three nodes 430, 440, and 450. Insuch an example, not all of the various nodes and/or mirrors may be upto date with a full set of log records. As described at FIG. 9, logrecord manipulation may be performed to facilitate reconcilingdifferences between log records stored at the various nodes.

In some embodiments, where a given log record is stored (e.g., whichnode or nodes) may be determined by the database engine head node andmay be included as routing information provided to the distributeddatabase-optimized storage system. Alternatively or in addition to,distributed database-optimized storage system may determine which nodeor nodes to store a given log record. In one embodiment, such adetermination by the distributed database-optimized storage system maybe to maximize performance by approximately proportionately distributingthe log records among the various nodes. In one embodiment, such adetermination by the distributed database-optimized storage system maydepend on an importance of a log record. For example, an AULR of animportant (e.g., frequently accessed) data page may be stored atmultiple nodes whereas a DULR associated with a less important data pagemay only be stored at a single node.

As described herein, log records may include DULRs and AULRs. In variousembodiments, an application, the database service, and/or a user of thedatabase service (or other component) may determine whether to create aDULR or AULR for a given change to a data page. For example, thedatabase service may ensure that at least one of every ten log recordsfor a given data page is an AULR. In such an example, if nine logrecords in a row for a given data page are DULRs, then the databaseservice may specify that the next log record be an AULR.

Further, in various embodiments, each data page in a volume may need anAULR. Therefore, for the first write of a data page, the log record maybe an AULR. In one embodiment, as part of a system initiation, each datapage may be written to a certain value (e.g., all zeroes) to initializethe data pages as an AULR. An all zeros AULR may suffice such thatsubsequent writes of the data page may be DULRs.

As shown at 820, a snapshot may be generated. In various embodiments,generating the snapshot may include generating metadata indicative of alog identifier (e.g., LSN) of a particular log record. In some examples,metadata indicative of one or more other log identifiers of otherparticular log records may also be generated. Such metadata indicativeof log identifier(s) of log record(s) may indicate that those particularlog records are to be kept (e.g., not deleted or garbage collected) forthat snapshot (until that snapshot is deleted or replaced).

In some embodiments, the generated metadata may also be indicative of asnapshot identifier. Example snapshot identifiers may include one ormore of a sequential number, a name, a time associated with thesnapshot. For example, a particular snapshot may be called SN1 and/ormay have a timestamp of Dec. 22, 2005 at 14:00.00 (2 pm exactly) GMT.

In various embodiments, the metadata associated with the snapshot may beusable to prevent one or more log records from being garbage collected.For example, the metadata may indicate one or more log records that areneeded to recreate a given page up to the log record/LSN associated withthe snapshot. As a result, the metadata may ensure that the data page(s)can be generated up to the LSN associated with the snapshot.

In various embodiments, the metadata may be stored in a variety ofdifferent locations. For example, the metadata may be stored within eachlog record and may indicate that respective log record's protection fromgarbage collection status. For example, if log records having LSNs 2, 3,and 4 should not be garbage collected for a particular snapshot, thenmetadata associated with the log records at LSNs 2, 3, and 4, shouldindicate that the log records at LSNs 2, 3, and 4 should not be garbagecollected. As another example, the snapshot metadata may be stored at ahigher level of the distributed database-optimized storage system (e.g.,at the segment, volume, or log record level, or elsewhere, etc.) and mayindicate the status of a plurality of log records' garbage collectionstatus. In such an example, the metadata include a list of LSNscorresponding to log records that should be retained per the snapshot.Note that upon taking a subsequent snapshot, the log record(s) to beretained may change. As a result, the metadata corresponding toparticular ones of the log records may also change. For instance, LSNs2, 3, and 4 may no longer need to be retained for a future snapshot.Accordingly, in such an example, the metadata may be modified such thatit no longer indicates that the log records corresponding to LSNs 2, 3,and 4 should be retained.

In one embodiment, the metadata may explicitly indicate which logrecords are not garbage collectable or it may instead indicate asnapshot type (described below) along with a particular LSNcorresponding to the snapshot. In such an embodiment, a garbagecollection process of the distributed database-optimized storage systemmay determine, from the snapshot type and the particular LSN, which logrecords are garbage collectable and which are not. For example, thegarbage collection process may determine that the log record associatedwith the particular LSN and each DULR back in time until the previousAULR for that data page are not garbage collectable.

In various embodiments, a snapshot may be specific to a particular datapage, or it may be specific to multiple data pages (e.g., segment,volume).

In one embodiment, the metadata may indicate a type of the snapshot(e.g., whether the snapshot is a continuous or a discrete snapshot), asdescribed herein. The type of the snapshot may be directly indicated(e.g., continuous or discrete) in the metadata or it may indirectlyindicated (e.g., which log record(s) are indicated as not garbagecollectable may be indicative of whether the snapshot is continuous ordiscrete). For example, a continuous snapshot may indicate one set oflog record(s) that are not garbage collectable whereas a discretesnapshot may indicate a different (e.g., smaller) set of log record(s)that are not garbage collectable. In some situations, a continuous anddiscrete snapshot may have metadata indicating the same set of logrecord(s). For example, for a snapshot of a data page taken at a pointin time corresponding to an AULR, the continuous and discrete snapshotmay both have metadata that indicates only the AULR should be protectedfrom garbage collection.

A continuous snapshot may be usable to restore the data to each point intime between the time of the continuous snapshot and a previous time(e.g., the most recent AULR). In contrast, a discrete snapshot may bereusable to restore data to the state as of the snapshot's point intime. For example, consider an example of a data page (AULR), with threedelta log records after that data page, followed by a new version of thedata page (AULR) and three more delta log records for that new versionof the data page. Using a snapshot to restore data is used herein todescribe reading the data as of the snapshot without making a copy ofthe previous version of the data. If a discrete snapshot is taken at thepoint in time after all of the entries (both AULRs and all six DULRs),then the log entries that may be indicated as not garbage collectableinclude the new version of the data page and the three log entries afterthat data page. If a continuous snapshot is taken from the currentsnapshot point in time to the point in time of the first version of thedata page, then the log entries that may be indicated as not garbagecollectable include the first data page and all six log records. Notethat the intermediate instantiated block (e.g., the new version of thedata page (AULR)) may not be indicated as not garbage collectablebecause it is recreatable with the first version of the data page andthe first three log records. Note that, in this example, the continuoussnapshot is usable to restore the data page to any of the points in timefor which log records exist whereas the discrete snapshot is usable torestore the data page to the point in time of the snapshot and to eachpoint in time between the point in time of the snapshot and the mostrecent AULRs before the snapshot.

In some embodiments, generating the snapshot may be performed withoutadditional reading, copying, or writing the data block, as would berequired when employing an off-volume backup strategy. Accordingly, thesnapshot may be generated in place such that the snapshot generation maynot requiring take a backup of the data. Note that backups of data wherethe data is also stored elsewhere may occur but such occurrence may beperformed outside of the snapshot generation process. For instance, aclient may request that multiple copies of the data be stored inseparate storage locations.

As illustrated at 830, the data may be read as of the statecorresponding to the snapshot. For example, if a user dropped a tablebut wants that table back, the snapshot can be used to read/restore thedata (e.g., data page, segment, volume, etc.) such that the table isavailable again. Note that reading/restoring the snapshot may includelosing some data/work that was performed after the point of the snapshotand may not include creating a copy of the previous version of the dataas part of the read/restore process.

Restoring the data to the state corresponding to the snapshot mayinclude applying one or more of the log records, including theparticular log record indicated in the metadata, to a previous versionof the data. The previous version of the data may be in the form of anAULR or it may be in the form of a DULR (as applied to an AULR and/orone or more DULRs before the DULR).

In some embodiments, applying the one or more log records to a previousversion of the data may be performed as a background process for thedatabase service. In one embodiment, applying the log record(s) to theprevious version of the data may be distributed across various nodes ofthe database service. In one embodiment, applying the log record(s) tothe previous version of the data may be performed in parallel acrossthose various nodes.

As shown at 840, after restoring to a particular snapshot, one or morelog records with associated times later than a time associated with thesnapshot may be indicated as garbage collectable. For example, if logrecords having LSNs 1-6 exist for a data page with a snapshot havingbeen taken at LSN 3, upon restoring the snapshot taken at LSN 3, LSNs4-6 may be indicated as garbage collectable or may simply have the notgarbage collectable indication removed (thereby making them garbagecollectable). Thus, even if a second snapshot was taken at LSN 6, uponrestoring the snapshot from LSN 3, the snapshot taken at LSN 6 may nolonger be in place such that the protection of log records correspondingto snapshot taken at LSN 6 may no longer be in effect. Or, in oneembodiment, the second snapshot may still be preserved even whenrestoring to a previous snapshot.

In various embodiments, garbage collection may be a background processthat permits space used to store log records to be reclaimed for otherlog records in the future (or for other data). Garbage collection may bespread across the various nodes such that garbage collection may occuras a distributed process in parallel. Reclaiming by the garbagecollection process may include deleting one or more log records. Thoselog records to delete may be determined by the garbage collectionprocess based on the particular log record(s) indicated in the metadataand/or may be based on the type of snapshot. Or, in one embodiment, inwhich each protected log record is explicitly indicated in metadata,then the garbage collection process may simply delete log records notindicated as protected in the metadata.

In some embodiments, a plurality of the log records may be coalescedbased, least in part, on the snapshot. For example, for a given datapage, if an AULR exists at LSN 1, DULRs exist at LSNs 2-8 and a discretesnapshot is taken at LSN 8, a new AULR may be created to replace theDULR at LSN 8 such that each of the log records from LSN 2-8 are appliedto the AULR at LSN 1. The new AULR at LSN 8 may then allow the logrecords at LSN 1-7 to be garbage collectable thereby freeing up thespace used to store those log records. Note that for a continuoussnapshot, coalescing may not take place to maintain the ability torestore to each of the points in time covered by the continuoussnapshot. Note that a client may request that continuous snapshots beretained for the two previous days and periodic (e.g., twice daily, oncedaily) discrete snapshots be retained for the thirty days before that.When a continuous snapshot falls outside of the previous two day range,it may be converted into a discrete snapshot, and the log records nolonger needed for the converted discrete snapshot may no longer beretained.

Consider an example in which a once daily discrete snapshot exists foreach of days 1-30 and continuous snapshots exist from day 30 to day 32.On day 33, the continuous snapshot from day 30 to day 31 may no longerbe needed by a client as it is no longer in the most recent two dayperiod. Accordingly, the continuous snapshot from day 30 to day 31 maybe converted into a discrete snapshot. To convert the portion of thecontinuous snapshot from day 30 to day 31 into a discrete snapshot, themetadata may be modified such that log record(s) no longer needed forthe discrete snapshot at that point in time may be indicated as garbagecollectable (or no longer indicated as not garbage collectable). Alongthe same lines, the discrete snapshot at day 1 may be deleted and/orgarbage collected as well (assuming the day 2 discrete snapshot is notdependent on the log records of the discrete snapshot at day 1) becauseit no longer falls within the preceding thirty day window before themost recent two days. Deleting the snapshot at day 1 may includemodifying and/or deleting the metadata that protected the log recordsassociated with the day 1 snapshot from being garbage collected (unlessneeded by a subsequent snapshot) such that those records may then begarbage collectable. Note that if the discrete snapshot at day 2includes is dependent on log records of the discrete snapshot at day 1,one or more log records associated with the discrete snapshot at day 2may be converted in AULR(s) such that the day 1 log records can bedeleted and/or garbage collected.

As described herein, the method of FIG. 8 may apply to data of a singledata page or to data from multiple data pages. Therefore, in variousembodiments, the snapshot may be usable to restore data from multipledifferent data pages or to a single data page. Accordingly, the metadataof the snapshot may be indicative of one or more log identifiers for oneor more particular log records for a single data page or multiple logidentifiers for multiple log records for multiple data pages. Furthernote that metadata corresponding to a snapshot for a single data pagemay, in some instances, also be indicative of multiple log identifiersfor multiple log records. For example, the metadata may be indicative ofmultiple log records that should not be garbage collected, such as ifthe snapshot corresponds to a DULR. In such an example, the metadata maybe indicative (directly or indirectly) that each DULR back in time tothe most recent AULR and the most recent AULR for that page should notbe garbage collected.

The disclosed in-place snapshot techniques may improve performance ofthe system in terms of using fewer IO and networking resources asopposed to a system that backs up the data to perform a snapshot byreading, copying, and writing of the data block. And because of thoseperformance improvements, the disclosed techniques may provide for fewertransaction rate stalls or throttling that would be visible to users ofthe system (e.g., those using the system for foreground activity).

Turning now to FIG. 9, in various embodiments, data base system 400 maybe configured to manipulate (e.g., transform, modify, etc.) log records.While the method of FIG. 9 may be described as being performed byvarious components of a log-structured storage system, such asdistributed database-optimized storage system 410 (e.g. storage systemserver node(s) 430, 440, 450, etc.), the method need not be performed byany specific component in some cases. For instance, in some cases, themethod of FIG. 9 may be performed by some other component or computersystem, according to some embodiments. Or, in some cases, components ofdatabase system 400 may be combined or exist in a different manner thanthat shown in the example of FIG. 4. In various embodiments, the methodof FIG. 9 may be performed by one or more computers of a distributeddatabase-optimized storage system, one of which is shown as the computersystem of FIG. 10. The method of FIG. 9 is shown as one exampleimplementation of a method for log transformation/manipulation. In otherimplementations, the method of FIG. 9 may include additional or fewerblocks than are shown. For example, the method of FIG. 9 may be used inconjunction with the method of FIG. 8 such that the method of FIG. 9includes one or more blocks of the method of FIG. 8.

At 910, a plurality of log records may be received. For example, the logrecords may be received by the distributed database-optimized storagesystem, from a database engine head node of the database service. Asnoted at FIG. 8, and as described herein, each log record may beassociated with a respective log sequence identifier and may beassociated with a respective change to data stored by the databasesystem. Also as described herein, log records may include one or moreAULRs, also referred to as baseline log record(s), and/or one or moreDULRs. The baseline log record(s) may include a page of data, such thatit includes the full data for the page and not just changes to the data.In contrast, DULRs may include a change to a page of data and not thefull page of data.

The following paragraphs describe an example notation to describe arange of log records. Simple brackets ( ) and square brackets [ ]indicate open (exclusive) and closed (inclusive) bounds in a range. Asdescribed herein, LSNs may be a sequential ordering of log records, suchthat 0<=a<=b<=c<=d<=e. LSN t is a special LSN that stands for tail,which starts from 0 and is continually increasing as writes occur on thevolume. As used herein, a log section is a collection of log recordsthat has all the information necessary to be able to read a volume atone or more target LSNs, given a volume at a baseline LSN. In oneembodiment, the log section does not contain any log record with LSNless than or equal to the baseline LSN or greater than the highesttarget LSN. For example, if there is a complete volume at a baseline LSNof ‘a’, and a log section is L(a;b], then the volume can be generatedand read at LSN ‘b’.

Using an example syntax, a log section may then be represented asL(<baseline LSN>;<set of target LSNs>]. In one embodiment, <baselineLSN> may be a single LSN (e.g., ‘0’ or ‘a’). <set of target LSNs> may bea single LSN (e.g., ‘b’), a sequence of discrete LSNs (e.g., ‘b,c’), aninclusive range of LSNs (e.g., ‘c..d’), or a combination thereof (e.g.,‘b, c, d..e’). An inclusive range, such as c..d indicates that enoughinformation is available to restore any volume between c and d.According to the example syntax, target LSNs are greater than or equalto the baseline LSN. Further according to the example syntax, LSNs of alog section are listed in ascending order.

In various embodiments, records in a log section can be a combination ofAULRs and/or DULRs. A log section may alternatively include only DULRsor only AULRs. For example, a log section may include only AULRs foruser pages that were modified between the baseline and target LSNs. Invarious embodiments, it is not required to be able to generate versionsof user pages at LSNs other than the target LSNs. For example, a logsection L(a;c] may not have enough information to generate user pages atLSN b where a<b<c.

Assuming that the initial state of a volume consists of all zeros, a logsection of the form L(0;a] may represent the volume at LSN a.

The log section notation described herein is indicative of LSNs for avolume that includes multiple data/user pages. For example, consider avolume that includes only two pages, x and y. A log record with LSN 1may be an AULR for page x and a log record with LSN 2 may be an AULR forpage y. Continuing the example, log records with LSNs 3 and 5 may beDULRs for page x and log records with LSNs 4 and 6 may be DULRs for pagey. If a read request comes in for page y, then the database service maystart with the AULR at LSN 2, which is the most recent AULR for page y,and apply the changes from LSNs 4 and 6 on top of that. Similarly, for aread request for page x, the database service would start with the AULRat LSN 1 and then apply the changes from the log records at LSNs 3 and 5before returning page x to the requestor.

As shown at 920, the plurality of log records may be stored among thestorage nodes of the distributed database-optimized storage system. Inone embodiment, a given log record may be stored at one or more storagenodes of the distributed database-optimized storage system. In oneembodiment, the distributed database-optimized storage system maydetermine which one or more storages nodes on which to store the givenlog record, or the distributed database-optimized storage system mayreceive instructions from the database engine head node that indicatesone or more storage nodes on which to store the given log record. Notethat in some instances, because each storage node may not store the sameone or more log records at a given time, one or more nodes and/ormirrors of the storage system may not be up to date with a complete setof the current log records.

As illustrated at 930, the plurality of log records may be transformed.As indicated in the example notation described herein, the plurality oflog records that may be transformed may include two or more logsections. Those two or more log sections may be operands for thetransformation. Various examples of log sections as operands (e.g.,L(a;c], L(a;b,d], L(a;b,c..e], etc.) are provided below. Transformationmay occur in a variety of manners. For example, in one embodiment,transforming the plurality of log records may result in a modifiedplurality of log records. The modified plurality of log records may be adifferent plurality of log records. The different plurality of logrecords may be fewer in number than the originally maintained pluralityof log records, greater in number, or equal in number but different inat least one of the log records. Transformation of the log records mayresult in a more efficient system (e.g., in terms of storage space,network usage, etc.)

In one embodiment, in a distributed system with a plurality of nodes andmirrors, some of the nodes and/or mirrors may be up to date, and somemay not be. In such an embodiment, transforming the plurality of logrecords may include determining that differences exist in log recordsmaintained at different ones of the storage nodes and reconciling thosedifferences in log records maintained at the various nodes. Reconcilingthe differences in log records may include generating and/orreconstructing a modified plurality of log records in the form of anoverall master log of log records that reconciles the various logrecords stored at the various nodes. In one embodiment, the master logmay be then be provided to the various nodes and/or mirrors tosynchronize the contents of the logs (e.g., by replacing a log that isnot up to date). Or, in one embodiment, the master log may be maintainedon a particular node. That master log may be deemed as the master log ofthe storage nodes until the next occurrence of log reconciliation.

To illustrate log reconciliation, consider a simple example with threestorage nodes, SN1, SN2, and SN3. SN1 may store log records havingidentifiers LSN 1, LSN 2, and LSN 3. SN2 may store log records havingidentifiers LSN 3, LSN 4, and LSN 5, and SN3 may store log record havingidentifier LSN 6. Transforming the log records may include generating amaster log record that includes once instance of LSNs 1-6 and not twoinstances of LSN 3, which was stored at both SN1 and SN2. Performing thelog reconciliation may include applying one or more log operations tothe log records. Example log operations include coalescing, pruning,cropping, reducing, fusing, and/or otherwise deleting or adding logrecords. Such example log operations are described in more detail below.

As described herein, in one embodiment, transforming the log records mayinclude coalescing the plurality of log records. Coalescing the logrecords may include converting a delta log record into a new baselinelog record. Consider an example for data pages x and y in which LSNs 1,2, 15, and 16 are identifiers of respective AULRs and LSNs 2-14 areidentifiers of respective DULRs. Coalescing the log records may includeconverting the DULR of LSN 8 to an AULR. To convert LSN 8 to an AULR,the changes from log records that correspond to the same data page asLSN 8 (e.g., data page y), including the log record at LSN 8, may beapplied to the most recent AULR for that data page. For example, if LSN2 corresponds to an AULR for data page y and LSNs 4, 6, and 8 correspondto DULRs for data page y, then converting the DULR at LSN 8 to an AULRincludes applying the changes of the log records at LSNs 4, 6, and 8 tothe AULR at LSN 2. As described herein, in certain situations, the logrecords at LSN 2, 4, and 6 may then be garbage collected or otherwisedeleted, whereas in other situations (e.g., for a continuous snapshot orother dependency), those LSNs may be retained until no longer needed.

In various embodiments, the plurality of log records may be associatedwith at least one snapshot (e.g., a snapshot as created according to themethod of FIG. 8) that is usable to restore data to a previous state. Insuch embodiments, transforming the plurality of records may includegarbage collecting one or more of the log records, based at least inpart, on the snapshot. For instance, continuing the previous coalescingexample, if LSNs 2, 4, and 6 are needed as part of a continuoussnapshot, then the log records corresponding to those LSNs may not begarbage collectable (and may not be coalesced in the first place). Incontrast, if those log records are not needed as part of a snapshot,then they may be garbage collected. For example, if a discrete snapshotexists at an LSN after LSNs 2, 4, and 6, for example, at LSN 10, thenthe log records at LSNs 2, 4, and 6 may not be needed because the logrecord at LSN 8 is an AULR. Therefore, the log records at LSNs 2, 4, and6 may be garbage collected.

As described herein, transforming the log records may include indicatingthat one or more log records are garbage collectable. In such anexample, transforming the log records to indicate one or more logrecords are garbage collectable may include generating and/or modifyingmetadata associated with those one or more log records to indicate thoselog records are garbage collectable.

In one embodiment, transforming the log records may include deleting oneor more log records. As described herein, deleting a log record may bepart of a prune or crop operation, among other operations. Deleting thelog record may be different that garbage collection, in someembodiments, in that garbage collection may be passively and lazilyperformed as a background process, whereas deletion may be performed asa foreground process.

In one embodiment, transforming the log records may include performing acrop operation to crop the plurality of log records. Performing the cropoperation may include deleting (and/or indicating as garbagecollectable) one or more log records having respective identifiers(e.g., LSN value) less than or less than or equal to the value of atarget identifier (e.g., target LSN). The crop operation may be used toincrease the baseline LSN of a log section. Note that the respectiveidentifiers may be sequentially ordered according to time, therefore, insome embodiments, cropping may include deleting the log records havingrespective associated times before an associated time of the targetidentifier.

In one embodiment, the left argument for the operation may be a logsection with baseline LSN B1 and the right argument may be a range ofLSNs to be removed. Accordingly, the result may be one or more logrecords having LSNs that start at a point in time corresponding to thetarget LSN. As one example, consider the following example cropoperation, with ‘−’ denoting crop, L(a;c]-(a,b]=L(b;c]. Thus, theportion (a,b] is cropped from (a;c] resulting in a new range of (b;c].As noted above, simple ( ) brackets may indicate open bounds in a rangeand square [ ] brackets may indicate closed bounds in a range. Asanother crop example, consider the crop operation L(a;b,d]−(a,c]. Theresult is L(c;d]. As yet another crop example, consider the cropoperation where L(a;b,c..e]−(a,d]=L(d;e].

As a result of the crop operation, one or more log records having an LSNless than or equal to the new baseline LSN may be deleted (or garbagecollected). In some examples, it is possible that the original logsection may not include any such log records to crop. In those examples,the crop operation may not result in a reduction in the size of the logsection.

In one embodiment, transforming the log records may include performing aprune operation to prune the plurality of log records. Performing theprune operation may include deleting (and/or indicating as garbagecollectable) one or more log records having respective identifiers(e.g., LSN value) greater than or greater than or equal to the value ofa target identifier (e.g., target LSN). The prune operation may be usedto remove a trailing portion of a log section. Similar to the cropoperation, because respective identifiers may be sequentially orderedaccording to time, in some embodiments, pruning may include deleting thelog records having respective associated times after an associated timeof the target identifier.

In one embodiment, the left argument for the prune operation may be alog section with target LSN(s) T1 and the right argument may be a newtarget LSN(s) T2, with T2 being a proper subset of T1. The pruneoperation may remove LSNs such that the removed LSNs are greater thanthe retained LSNs. For example, for LSNs L3 in {T1−T2} with L2 in T2,the following condition may hold true: L3>L2.

As one example, consider the following example prune operation, with ‘@’denoting crop, L(a;b,c]@[b]=L(a;b]. Thus, the portion of log recordswith respective identifiers greater than the target identifier b isdeleted from the log section L(a;b,c]. Another example includesL(a;b..d]@[b..c]=L(a;b..c]. As was the case with the crop operation, theprune operation, the original log section may not include any such logrecords to prune. In those examples, the prune operation may not resultin a reduction in the size of the log section.

In one embodiment, transforming the log records may include reducing theplurality of log records. The reduce operation may reduce the set oftarget LSNs of a log section without changing the highest target LSN.Accordingly, the reduce operation may be a complementary operation tothe prune operation. Reducing may not cut the head or tail end of a logsection but instead may remove a middle portion of the section. Anexample of a reduce operation would be to remove the continuous portionof a snapshot. For instance, if a continuous snapshot is requested forthe last two days and discrete snapshots requested for the last 30 days,once a portion of the continuous snapshot is greater than two days old,a portion may be removed thereby resulting in one or more discretesnapshots.

The reduce operation may be denoted by ‘@@’. The left argument to thereduce operation may be a log section with target LSN T1 with the rightargument being the next target LSN T2, with T2 being a proper subset ofT1. The highest LSN in T1 may be equal to the highest LSN in T2. As anexample, L(a;b..c]@@[c] may result in L(a;c]. As another example,L(a;a..b,c..e]@@[b,d..e] may result in L(a;b,d..e]. Note that no logrecords may be required to be deleted as part of the reduce operation.In some examples, some log records may not be required to generate userpage versions at the new target LSNs. Those log records may be deletedsafely but are not required to be deleted. Those log records can be leftin place and/or garbage collected lazily. Identifying which log recordsare deletable (e.g., via deletion or garbage collection) may bedetermined based on determined dependencies among the plurality of logrecords. For example, certain DULRs may be dependent on one or moreprevious DULRs and/or a previous AULR. Therefore, in one embodiment, alog record that is deletable and does not have other log recordsdependent upon it may be deleted and/or garbage collectable whereas alog record that would otherwise be deletable but has other log recordsdependent on it may be kept and not deleted or garbage collected.

Note that in some embodiments, while it is possible to increase thebaseline LSN in a flexible way (e.g., using the crop operation), asimilar decrease in target LSN may not be available. For example, whileL(a;c] may be transformed into L(b;c], in some embodiments, it may notbe transformed into L(a;b] because L(a;c] may be missing some logrecord(s) between a and b, which were superseded by AULR(s) between band c. Thus, L(a;c] may lack enough information to generate the wholevolume at LSN b. The new target LSN set of a log section may have to bea subset of the previous target LSN set. For example, L(a;b..c] andL(a;a..c] may not have the necessary information to generate the wholevolume at LSN b but can be transformed into L(a;b] using prune andreduce operations.

In one embodiment, transforming the log records may include combiningthe plurality of log records with another plurality of log records in afuse operation. For example, the fuse operation may include combiningtwo adjacent log sections into a single log section such that the targetLSNs of both log sections are retained. The fusion operation may berepresented by ‘+’. The left argument may include a log section with alower baseline LSN B1 with the highest target LSN being T1. The rightargument may include a log section with a higher baseline LSN B2. B2 isequal to T1 in some embodiments. One example fuse operation isL(a;b]+L(b;c]=L(a;b,c]. Another example fuse operation isL(a;b,c]+L(c;d,e]=L(a;b,c,d,e]. In various embodiments, no log recordsmay be deleted as part of a fuse operation.

In one embodiment, if garbage collection is performed without retainingany snapshots, the log can be represented by L(0;t]. If no garbagecollection is performed, the log can be represented by L(0;0..t].

A notation for representing a volume at LSN ‘a’ may be V[a]. V[0] can beassumed to include all zeroes. In one embodiment, transforming the logrecords of a volume may include a constitute operation, represented by‘*’. A new volume may be created as a higher LSN given a volume at alower LSN and a log section corresponding to the LSN gap. The leftargument may be a volume at LSN B and the right argument may be a logsection with baseline LSN B and a single target LSN T. A log sectionwith multiple target LSNs may be pruned and/or reduced to the single LSNof interest before constituting the desired volume. An example includesV[a]*L(a;b]=V[b].

In one embodiment, transforming the log records may include performingcombinations of operations to the plurality of log records. Consider thefollowing derived transformation from a combination of operations:{L(b;c],L(b;d]} L(b;c,d]. Such a transformation may be derived from cropand fuse operations as follows: L(b;d]-(b,c]=L(c;d] andL(b;c]+L(c;d]=L(B;c,d]. Another example derived transformation extendsthe previous example: {L(a;c],L(b;d]}→L(b;c,d], which includes the cropand fuse from the previous example and further includes an additionalcrop L(a;c]-(a,b]=L(b;c]. Note that the use of represents a generictransformation without showing the details of the operations. Forexample, {L1,L2}→{L3} is a transformation from L1 and L2 to L3 withoutshowing the underlying operations to perform the transform.

In various embodiments, performing combinations of multiple operationson the plurality of log records may facilitate snapshot operations(e.g., as part of taking, restoring, truncating, and/or deleting asnapshot as in FIG. 8), or log record reconciliation, among otheroperations. Example combinations for taking, restoring, and deletingdiscrete and continuous snapshots follow.

For an example of combining operations to take a discrete snapshot, aninitial state of a live log for the distributed storage system may beL(0;t]. A snapshot may be taken when the tail reaches LSN a, L(0;a,t].L(0;a,t] may then be pruned at [a], L(0;a,t]@[a]=L(0;a]. L(0;a] may becopied to a snapshot storage location, which may be a separate storagelocation than the distributed storage system. Another snapshot may betaken when the tail reaches LSN b, L(0;a,b,t]. L(0;a,b,t] may then becropped according to L(0;a,b,t]-(0,a], resulting in L(a;b,t). L(a;b,t)may then be pruned at [b] (L(a;b,)@[b]) resulting in L(a;b]. L(a;b] maythen be copied to the snapshot storage location as well.

For an example of combining operations to restore a discrete snapshot,consider the following to be available at the snapshot storage location:L(0;a],L(a;b]. L(0;a] and L(a;b] may be copied to the restoredestination and may be fused according to L(0;a]+L(a;b]=L(0;a,b]. Thefused section may then be reduced according to L(0;a,b]@@[b]=L(0;b].L(0;b] may be the desired snapshot to restore and may be used to start anew volume.

For an example of combining operations to delete an old discretesnapshot, consider the following initial live log state L(0;a,b,t].L(a;a,b,t]@@[b,t]=L(0;b,t] may be used to delete a snapshot at a andL(0;a,b,t]@@[t]=L(0;t] may be used to delete both snapshots a and b.

For an example of combining operations to take a continuous snapshot, aninitial state of a live log for the distributed storage system may beL(0;t] as was the case in the discrete snapshot taking example. Acontinuous snapshot make be begun when the tail reaches LSN a, asindicated by L(0;a..t]. After the tail crosses LSN b (b<t), L(0;.a..t]can be pruned (@@) by [a..b] giving L(0;a..b]. L(0;a..b] may then becopied to the snapshot storage location. After the tail cross LSN c(c<t), L(0;a..t]@@[a..c]=L(0;a..c). L(0;a..c)@@[b..c]=L(0;b..c].L(0;b..c] may then be cropped at (0,a] giving L(b;b..c], which may thenbe copied to the snapshot storage location. The continuous snapshot maybe stropped when the tail reaches LSN d: L(0,a..d,t].

For an example of combining operations to restore a continuous snapshot,consider the following to be available at the snapshot storage location:L(0;a..b], and L(b;b..c]. L(0;a..b], and L(b;b..c] may be copied to arestore destination where the two log sections may be fused together asL(0;a..b]+L(b;b..c]=L(0;a..c]. If restore was requested for an LSN x,where b≦x≦c, then the following may be performed: L(0;a..c]@[a..x]=L(0;a..x]. The result may then be reduced (@@) at [x] resultingin L(0;x]. The desired snapshot may be L(0;x] and may be used to start anew volume.

Consider the following examples of combining operations to delete acontinuous snapshot with initial state of the live log beingL(0,a..d,t]. L(0,a..d,t] may be reduced by [t] to delete the entirecontinuous snapshot resulting in L(0;t] (log section with no retainedsnapshots). As another example, L(0,a..d,t] may be reduced by [a..c,t]to delete a part of the continuous snapshot from c to d resulting inL(0,a..c,t]. As another example, L(0,a..d,t] may be reduced by [c..d,t]to delete a part of the continuous snapshot from a to c resulting inL(0,c..d,t].

Consider the following example of truncating a current continuoussnapshot with initial state of the live log being L(0,a..t], where c<t.L(0,a..t]@@[c..t]=L(0;c..t], which may contain only a recent part of thecurrent continuous snapshot.

In various embodiments, the database service may receive a request, froma user, of time frames, ranges, or windows in which to snapshot and/ormay receive an indication of the type of requested snapshot (e.g.,continuous or discrete). For example, a user may request that they wantcontinuous snapshots for the previous two days and discrete snapshotsfor the previous thirty days. The database service may then determinewhich log record operation(s) (e.g., crop, reduce, prune, etc.) toperform on the log sections to satisfy the user's request. Continuingthe example, once a portion of a continuous snapshot is more than twodays old, the system may determine that a reduce operation isappropriate to reclaim space (e.g., via garbage collection) for logrecords that are no longer needed.

The methods described herein may in various embodiments be implementedby any combination of hardware and software. For example, in oneembodiment, the methods may be implemented by a computer system (e.g., acomputer system as in FIG. 10) that includes one or more processorsexecuting program instructions stored on a computer-readable storagemedium coupled to the processors. The program instructions may beconfigured to implement the functionality described herein (e.g., thefunctionality of various servers and other components that implement thedatabase services/systems and/or storage services/systems describedherein).

FIG. 10 is a block diagram illustrating a computer system configured toimplement at least a portion of the database systems described herein,according to various embodiments. For example, computer system 1000 maybe configured to implement a database engine head node of a databasetier, or one of a plurality of storage nodes of a separate distributeddatabase-optimized storage system that stores database tables andassociated metadata on behalf of clients of the database tier, indifferent embodiments. Computer system 1000 may be any of various typesof devices, including, but not limited to, a personal computer system,desktop computer, laptop or notebook computer, mainframe computersystem, handheld computer, workstation, network computer, a consumerdevice, application server, storage device, telephone, mobile telephone,or in general any type of computing device.

Computer system 1000 includes one or more processors 1010 (any of whichmay include multiple cores, which may be single or multi-threaded)coupled to a system memory 1020 via an input/output (I/O) interface1030. Computer system 1000 further includes a network interface 1040coupled to I/O interface 1030. In various embodiments, computer system1000 may be a uniprocessor system including one processor 1010, or amultiprocessor system including several processors 1010 (e.g., two,four, eight, or another suitable number). Processors 1010 may be anysuitable processors capable of executing instructions. For example, invarious embodiments, processors 1010 may be general-purpose or embeddedprocessors implementing any of a variety of instruction setarchitectures (ISAs), such as the x86, PowerPC, SPARC, or MIPS ISAs, orany other suitable ISA. In multiprocessor systems, each of processors1010 may commonly, but not necessarily, implement the same ISA. Thecomputer system 1000 also includes one or more network communicationdevices (e.g., network interface 1040) for communicating with othersystems and/or components over a communications network (e.g. Internet,LAN, etc.). For example, a client application executing on system 1000may use network interface 1040 to communicate with a server applicationexecuting on a single server or on a cluster of servers that implementone or more of the components of the database systems described herein.In another example, an instance of a server application executing oncomputer system 1000 may use network interface 1040 to communicate withother instances of the server application (or another serverapplication) that may be implemented on other computer systems (e.g.,computer systems 1090).

In the illustrated embodiment, computer system 1000 also includes one ormore persistent storage devices 1060 and/or one or more I/O devices1080. In various embodiments, persistent storage devices 1060 maycorrespond to disk drives, tape drives, solid state memory, other massstorage devices, or any other persistent storage device. Computer system1000 (or a distributed application or operating system operatingthereon) may store instructions and/or data in persistent storagedevices 1060, as desired, and may retrieve the stored instruction and/ordata as needed. For example, in some embodiments, computer system 1000may host a storage system server node, and persistent storage 1060 mayinclude the SSDs attached to that server node.

Computer system 1000 includes one or more system memories 1020 that areconfigured to store instructions and data accessible by processor(s)1010. In various embodiments, system memories 1020 may be implementedusing any suitable memory technology, (e.g., one or more of cache,static random access memory (SRAM), DRAM, RDRAM, EDO RAM, DDR 10 RAM,synchronous dynamic RAM (SDRAM), Rambus RAM, EEPROM,non-volatile/Flash-type memory, or any other type of memory). Systemmemory 1020 may contain program instructions 1025 that are executable byprocessor(s) 1010 to implement the methods and techniques describedherein. In various embodiments, program instructions 1025 may be encodedin platform native binary, any interpreted language such as Java™byte-code, or in any other language such as C/C++, Java™, etc., or inany combination thereof. For example, in the illustrated embodiment,program instructions 1025 include program instructions executable toimplement the functionality of a database engine head node of a databasetier, or one of a plurality of storage nodes of a separate distributeddatabase-optimized storage system that stores database tables andassociated metadata on behalf of clients of the database tier, indifferent embodiments. In some embodiments, program instructions 1025may implement multiple separate clients, server nodes, and/or othercomponents.

In some embodiments, program instructions 1025 may include instructionsexecutable to implement an operating system (not shown), which may beany of various operating systems, such as UNIX, LINUX, Solaris™, MacOS™,Windows™, etc. Any or all of program instructions 1025 may be providedas a computer program product, or software, that may include anon-transitory computer-readable storage medium having stored thereoninstructions, which may be used to program a computer system (or otherelectronic devices) to perform a process according to variousembodiments. A non-transitory computer-readable storage medium mayinclude any mechanism for storing information in a form (e.g., software,processing application) readable by a machine (e.g., a computer).Generally speaking, a non-transitory computer-accessible medium mayinclude computer-readable storage media or memory media such as magneticor optical media, e.g., disk or DVD/CD-ROM coupled to computer system1000 via I/O interface 1030. A non-transitory computer-readable storagemedium may also include any volatile or non-volatile media such as RAM(e.g. SDRAM, DDR SDRAM, RDRAM, SRAM, etc.), ROM, etc., that may beincluded in some embodiments of computer system 1000 as system memory1020 or another type of memory. In other embodiments, programinstructions may be communicated using optical, acoustical or other formof propagated signal (e.g., carrier waves, infrared signals, digitalsignals, etc.) conveyed via a communication medium such as a networkand/or a wireless link, such as may be implemented via network interface1040.

In some embodiments, system memory 1020 may include data store 1045,which may be configured as described herein. For example, theinformation described herein as being stored by the database tier (e.g.,on a database engine head node), such as a transaction log, an undo log,cached page data, or other information used in performing the functionsof the database tiers described herein may be stored in data store 1045or in another portion of system memory 1020 on one or more nodes, inpersistent storage 1060, and/or on one or more remote storage devices1070, at different times and in various embodiments. Similarly, theinformation described herein as being stored by the storage tier (e.g.,redo log records, coalesced data pages, and/or other information used inperforming the functions of the distributed storage systems describedherein) may be stored in data store 1045 or in another portion of systemmemory 1020 on one or more nodes, in persistent storage 1060, and/or onone or more remote storage devices 1070, at different times and invarious embodiments. In general, system memory 1020 (e.g., data store1045 within system memory 1020), persistent storage 1060, and/or remotestorage 1070 may store data blocks, replicas of data blocks, metadataassociated with data blocks and/or their state, database configurationinformation, and/or any other information usable in implementing themethods and techniques described herein.

In one embodiment, I/O interface 1030 may be configured to coordinateI/O traffic between processor 1010, system memory 1020 and anyperipheral devices in the system, including through network interface1040 or other peripheral interfaces. In some embodiments, I/O interface1030 may perform any necessary protocol, timing or other datatransformations to convert data signals from one component (e.g., systemmemory 1020) into a format suitable for use by another component (e.g.,processor 1010). In some embodiments, I/O interface 1030 may includesupport for devices attached through various types of peripheral buses,such as a variant of the Peripheral Component Interconnect (PCI) busstandard or the Universal Serial Bus (USB) standard, for example. Insome embodiments, the function of I/O interface 1030 may be split intotwo or more separate components, such as a north bridge and a southbridge, for example. Also, in some embodiments, some or all of thefunctionality of I/O interface 1030, such as an interface to systemmemory 1020, may be incorporated directly into processor 1010.

Network interface 1040 may be configured to allow data to be exchangedbetween computer system 1000 and other devices attached to a network,such as other computer systems 1090 (which may implement one or morestorage system server nodes, database engine head nodes, and/or clientsof the database systems described herein), for example. In addition,network interface 1040 may be configured to allow communication betweencomputer system 1000 and various I/O devices 1050 and/or remote storage1070. Input/output devices 1050 may, in some embodiments, include one ormore display terminals, keyboards, keypads, touchpads, scanning devices,voice or optical recognition devices, or any other devices suitable forentering or retrieving data by one or more computer systems 1000.Multiple input/output devices 1050 may be present in computer system1000 or may be distributed on various nodes of a distributed system thatincludes computer system 1000. In some embodiments, similar input/outputdevices may be separate from computer system 1000 and may interact withone or more nodes of a distributed system that includes computer system1000 through a wired or wireless connection, such as over networkinterface 1040. Network interface 1040 may commonly support one or morewireless networking protocols (e.g., Wi-Fi/IEEE 802.11, or anotherwireless networking standard). However, in various embodiments, networkinterface 1040 may support communication via any suitable wired orwireless general data networks, such as other types of Ethernetnetworks, for example. Additionally, network interface 1040 may supportcommunication via telecommunications/telephony networks such as analogvoice networks or digital fiber communications networks, via storagearea networks such as Fibre Channel SANs, or via any other suitable typeof network and/or protocol. In various embodiments, computer system 1000may include more, fewer, or different components than those illustratedin FIG. 10 (e.g., displays, video cards, audio cards, peripheraldevices, other network interfaces such as an ATM interface, an Ethernetinterface, a Frame Relay interface, etc.)

It is noted that any of the distributed system embodiments describedherein, or any of their components, may be implemented as one or moreweb services. For example, a database engine head node within thedatabase tier of a database system may present database services and/orother types of data storage services that employ the distributed storagesystems described herein to clients as web services. In someembodiments, a web service may be implemented by a software and/orhardware system designed to support interoperable machine-to-machineinteraction over a network. A web service may have an interfacedescribed in a machine-processable format, such as the Web ServicesDescription Language (WSDL). Other systems may interact with the webservice in a manner prescribed by the description of the web service'sinterface. For example, the web service may define various operationsthat other systems may invoke, and may define a particular applicationprogramming interface (API) to which other systems may be expected toconform when requesting the various operations.

In various embodiments, a web service may be requested or invokedthrough the use of a message that includes parameters and/or dataassociated with the web services request. Such a message may beformatted according to a particular markup language such as ExtensibleMarkup Language (XML), and/or may be encapsulated using a protocol suchas Simple Object Access Protocol (SOAP). To perform a web servicesrequest, a web services client may assemble a message including therequest and convey the message to an addressable endpoint (e.g., aUniform Resource Locator (URL)) corresponding to the web service, usingan Internet-based application layer transfer protocol such as HypertextTransfer Protocol (HTTP).

In some embodiments, web services may be implemented usingRepresentational State Transfer (“RESTful”) techniques rather thanmessage-based techniques. For example, a web service implementedaccording to a RESTful technique may be invoked through parametersincluded within an HTTP method such as PUT, GET, or DELETE, rather thanencapsulated within a SOAP message.

The various methods as illustrated in the figures and described hereinrepresent example embodiments of methods. The methods may be implementedmanually, in software, in hardware, or in a combination thereof. Theorder of any method may be changed, and various elements may be added,reordered, combined, omitted, modified, etc.

Although the embodiments above have been described in considerabledetail, numerous variations and modifications may be made as wouldbecome apparent to those skilled in the art once the above disclosure isfully appreciated. It is intended that the following claims beinterpreted to embrace all such modifications and changes and,accordingly, the above description to be regarded in an illustrativerather than a restrictive sense.

1. A system, comprising: one or more computing nodes, each of whichcomprises at least one processor and a memory, wherein the one or morecomputing nodes are configured to collectively implement a distributedlog-structured storage system of a database service configured to:receive a plurality of log records, wherein each of the plurality of logrecords is associated with a respective change to data stored by thedistributed log-structured storage system, wherein each of the pluralityof log records is associated with a respective log sequence number of aplurality of log sequence numbers; and generate a snapshot that isusable to read data as of a state corresponding to the snapshot, whereinsaid generating the snapshot includes: generating metadata that isindicative of a snapshot identifier and is further indicative of one ofthe plurality of log sequence numbers that is associated with aparticular one of the plurality of log records; wherein said generatingthe snapshot is performed without reading, copying, or writing a page ofthe data as part of said generating the snapshot.
 2. The system of claim1, wherein the metadata is usable to prevent one or more of the logrecords from being garbage collected.
 3. The system of claim 1, whereinthe metadata is further indicative of another one of the plurality oflog sequence numbers that is associated with another particular one ofthe plurality of log records.
 4. The system of claim 1, wherein themetadata indicates the snapshot is a continuous snapshot, wherein thecontinuous snapshot is usable to restore the data to a plurality ofpoints in time between first and second points in time.
 5. A method,comprising: performing, by one or more computers of a database service:maintaining a plurality of log records, wherein each of the plurality oflog records is associated with a respective change to data stored by thedatabase service; and generating a snapshot that is usable to read thedata as of a state corresponding to the snapshot, wherein saidgenerating the snapshot includes generating metadata that is indicativeof a particular log identifier of a particular one of the log records;wherein said generating the snapshot is performed without reading,copying, or writing a page of the data as part of said generating thesnapshot.
 6. The method of claim 5, wherein the metadata is usable toprevent one or more of the log records including the particular logrecord from being deleted.
 7. The method of claim 5, wherein themetadata indicates whether a type of the snapshot is continuous ordiscrete.
 8. The method of claim 5, further comprising: reading the dataas of the state corresponding to the snapshot, wherein said readingincludes applying one or more of the log records including theparticular log record to a previous version of the data without making acopy of the previous version of the data.
 9. The method of claim 8,wherein said applying is performed as a background process for thedatabase service.
 10. The method of claim 8, wherein said applying isperformed in parallel across various nodes of the database service. 11.The method of claim 5, further comprising: deleting one or more of thelog records based, at least in part, on the metadata not indicating thatthe one or more of the log records are protected from garbagecollection.
 12. The method of claim 5, further comprising: determiningthat one or more of the log records are to be deleted based, at least inpart, on a type of the snapshot; and deleting the one or more of the logrecords.
 13. The method of claim 5, further comprising: restoring thedata to the state corresponding to the snapshot; and indicating that oneor more log records associated with times later than a time associatedwith the snapshot are garbage collectable.
 14. The method of claim 5,further comprising: coalescing a plurality of the log records based, atleast in part, on the snapshot.
 15. A non-transitory computer-readablestorage medium storing program instructions, wherein the programinstructions are computer-executable to implement a distributed storagesystem configured to: store a plurality of log records at a plurality ofnodes of the distributed storage system, wherein each of the pluralityof log records is associated with a respective change to a data page;and generating a snapshot that is usable to read the data page as of astate corresponding to the snapshot, wherein said generating thesnapshot includes generating metadata that is indicative of a timeassociated with a particular one of the plurality of log records;wherein said generating the snapshot is performed without reading,copying, or writing a page of the data as part of said generating thesnapshot.
 16. The non-transitory computer-readable storage medium ofclaim 15, wherein the metadata is usable to prevent one or more of thelog records from being garbage collected.
 17. The non-transitorycomputer-readable storage medium of claim 15, wherein the distributedstorage system is further configured to: store another plurality of logrecords at the plurality of nodes of the distributed storage system,wherein each of the another plurality of log records are associated witha respective change of another data page; and wherein the snapshot isfurther usable to read the other data page as of the state correspondingto the snapshot, wherein the metadata is further indicative of aparticular one of the other plurality of log records.
 18. Thenon-transitory computer-readable storage medium of claim 15, wherein thedistributed storage system is further configured to: read the data pageas of the state corresponding to the snapshot; and indicate that one ormore log records associated with times later than a time associated withthe snapshot are garbage collectable.
 19. The non-transitorycomputer-readable storage medium of claim 15, wherein the distributedstorage system is further configured to: read the data page as of thestate corresponding to the snapshot, wherein said reading includesapplying one or more of the log records including the particular logrecord to a previous version of the data page without making a copy ofthe previous version of the data page.
 20. The non-transitorycomputer-readable storage medium of claim 19, wherein said applying isdistributed across the plurality of nodes of the distributed storagesystem.